my-flan-json / app.py
Teja9398's picture
Create app.py
bf278fc verified
raw
history blame
597 Bytes
import gradio as gr
from transformers import pipeline
# Load the model
pipe = pipeline("text2text-generation", model="google/flan-t5-base")
def convert_to_json(text):
prompt = f"Convert this to JSON: {text}"
output = pipe(prompt, max_new_tokens=200)[0]["generated_text"]
return output
gr.Interface(
fn=convert_to_json,
inputs=gr.Textbox(lines=2, placeholder="Enter something like: I spent 2500 on a medical check-up today"),
outputs=gr.Textbox(label="Generated JSON"),
title="Natural Language to JSON Converter",
description="Powered by flan-t5-base"
).launch()