Spaces:
Runtime error
Runtime error
File size: 833 Bytes
74a9c90 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
import gradio as gr
from brain import img2txt, generate_story
import os
def generate_story_from_image(image):
# Save the uploaded image temporarily
temp_image_path = "temp_image.jpg"
image.save(temp_image_path)
# Generate text from the image
scenario = img2txt(temp_image_path)
# Generate a story based on the scenario
story = generate_story(scenario)
# Remove the temporary image file
os.remove(temp_image_path)
return story
# Create the Gradio interface
iface = gr.Interface(
fn=generate_story_from_image,
inputs=gr.Image(type="pil"),
outputs="text",
title="Kids Story Generator",
description="Upload an image and get a kids story based on it!",
examples=[["example_image.jpg"]],
)
# Launch the app
if __name__ == "__main__":
iface.launch() |