Teja9398 commited on
Commit
bf278fc
·
verified ·
1 Parent(s): f693aa6

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -0
app.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Load the model
5
+ pipe = pipeline("text2text-generation", model="google/flan-t5-base")
6
+
7
+ def convert_to_json(text):
8
+ prompt = f"Convert this to JSON: {text}"
9
+ output = pipe(prompt, max_new_tokens=200)[0]["generated_text"]
10
+ return output
11
+
12
+ gr.Interface(
13
+ fn=convert_to_json,
14
+ inputs=gr.Textbox(lines=2, placeholder="Enter something like: I spent 2500 on a medical check-up today"),
15
+ outputs=gr.Textbox(label="Generated JSON"),
16
+ title="Natural Language to JSON Converter",
17
+ description="Powered by flan-t5-base"
18
+ ).launch()