sap_search / app.py
Preetham04's picture
Update app.py
c6d4788 verified
raw
history blame
1.42 kB
"""import gradio as gr
from transformers import pipeline
pipeline = pipeline(task="text-generation", model="Preetham04/text-generation")
def predict(input_img):
predictions = pipeline(input_img)
return {p["title"] for p in predictions}
gradio_app = gr.Interface(
predict,
inputs="textbox",
outputs="text",
title="Text-generation",
)
if __name__ == "__main__":
gradio_app.launch(share=True)
"""
"""
import gradio as gr
from transformers import pipeline
pipe = pipeline("text-generation", model="Preetham04/text-generation")
def generate(text):
return pipe(text)[0]["title"]
with gr.Blocks() as demo:
with gr.Row():
with gr.Column():
find = gr.Textbox(label="input text")
search_btn = gr.Button(value="SEARCH")
with gr.Column():
found = gr.Textbox(label="Related searches")
search_btn.click(generate, inputs=find, outputs=found)
examples = gr.Examples(examples=["SDE", "UX"],
inputs=[find])
demo.launch()
"""
import gradio as gr
description = "Story generation with GPT-2"
title = "Generate your own story"
examples = [["Adventurer is approached by a mysterious stranger in the tavern for a new quest."]]
interface = gr.Interface.load("huggingface/pranavpsv/gpt2-genre-story-generator",
description=description,
examples=examples
)
interface.launch()