Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,22 +1,11 @@
|
|
| 1 |
-
import pandas as pd
|
| 2 |
-
import gradio as gr
|
| 3 |
from transformers import pipeline
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
| 7 |
|
| 8 |
-
|
|
|
|
|
|
|
| 9 |
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
result = qa_pipeline(question=question, context=context)
|
| 13 |
-
return result['answer']
|
| 14 |
-
except Exception as e:
|
| 15 |
-
return str(e)
|
| 16 |
-
|
| 17 |
-
iface = gr.Interface(
|
| 18 |
-
fn=answer_query,
|
| 19 |
-
inputs=gr.Textbox(label="Enter your question:"),
|
| 20 |
-
outputs=gr.Textbox(label="Answer:")
|
| 21 |
-
)
|
| 22 |
-
iface.launch()
|
|
|
|
|
|
|
|
|
|
| 1 |
from transformers import pipeline
|
| 2 |
|
| 3 |
+
model_path = '/content/model_output'
|
| 4 |
+
text_gen = pipeline("text-generation", model=model_path, tokenizer=model_path)
|
| 5 |
|
| 6 |
+
def answer_question(question):
|
| 7 |
+
result = text_gen(question, max_length=100, num_return_sequences=1)
|
| 8 |
+
return result[0]['generated_text']
|
| 9 |
|
| 10 |
+
iface = gr.Interface(fn=answer_question, inputs="text", outputs="text")
|
| 11 |
+
iface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|