tournas commited on
Commit
5bdc889
·
verified ·
1 Parent(s): 85a2854

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -8
app.py CHANGED
@@ -65,15 +65,29 @@ def text_to_speech(story):
65
  tts.save(audio_file_path)
66
  return audio_file_path
67
 
68
- detect_interface = gr.Interface(fn=detect_objects, inputs="image", outputs="text", title="Object Detection")
69
- story_interface = gr.Interface(fn=generate_story, inputs="text", outputs="text", title="Story Generation")
70
- summary_interface = gr.Interface(fn=summarize_story, inputs="text", outputs="text", title="Story Summarization")
71
- image_interface = gr.Interface(fn=generate_images, inputs="text", outputs="image", title="Image Generation")
72
- audio_interface = gr.Interface(fn=text_to_speech, inputs="text", outputs="audio", title="Text to Speech")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
 
74
- # Συνδυασμός των interfaces σε ένα Gradio Tabbed Interface
75
- demo = gr.TabbedInterface([detect_interface, story_interface, summary_interface, image_interface, audio_interface],
76
- ["Detect Objects", "Generate Story", "Summarize Story", "Generate Images", "Text to Speech"])
77
 
78
  if __name__ == "__main__":
79
  demo.launch()
 
65
  tts.save(audio_file_path)
66
  return audio_file_path
67
 
68
+ def full_pipeline(image):
69
+ detected_objects = detect_objects(image)
70
+ story = generate_story(detected_objects)
71
+ scenes = summarize_story(story)
72
+ images = generate_images(scenes)
73
+ audio = text_to_speech(story)
74
+
75
+ return story, scenes, images, audio
76
+
77
+ # **Gradio UI**
78
+ demo = gr.Interface(
79
+ fn=full_pipeline,
80
+ inputs=gr.Image(type="pil"),
81
+ outputs=[
82
+ gr.Textbox(label="Generated Story"),
83
+ gr.Textbox(label="Story Scenes"),
84
+ gr.Gallery(label="Generated Images"),
85
+ gr.Audio(label="Story Audio"),
86
+ ],
87
+ title="AI-Powered Storytelling Assistant",
88
+ description="Upload an image, and the AI will detect objects, generate a story, create images, and narrate the story."
89
+ )
90
 
 
 
 
91
 
92
  if __name__ == "__main__":
93
  demo.launch()