AMfeta99 commited on
Commit
f7c1e90
·
verified ·
1 Parent(s): 21bbd84

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -14
app.py CHANGED
@@ -82,7 +82,14 @@ llm_engine = HfApiEngine("Qwen/Qwen2.5-72B-Instruct")
82
  agent = ReactCodeAgent(tools=[image_generation_tool, search_tool], llm_engine=llm_engine)
83
 
84
 
85
- # Your existing generate_object_history function goes here
 
 
 
 
 
 
 
86
 
87
  # Gradio interface
88
  def create_gradio_interface():
@@ -92,23 +99,17 @@ def create_gradio_interface():
92
  # Add a section for instructions
93
  gr.Markdown("""
94
  ## Welcome to the Object Evolution Generator!
95
-
96
  This app allows you to generate visualizations of how an object, like a bicycle or a car, may have evolved over time.
97
  It generates images of the object in the past, present, and future based on your input.
98
-
99
- ### How to use:
100
- - Enter the name of an object (e.g., "bicycle", "car", "phone").
101
- - Click "Generate Evolution" to generate the evolution of the object across three time periods: past, present, and future.
102
- - View the generated images and a GIF showing the evolution of the object.
103
-
104
- ### Example:
105
- Try entering an object name like "car" and see how it has evolved!
106
  """)
107
 
108
  with gr.Row():
109
  with gr.Column():
110
  # Textbox for user to input an object name
111
- object_name_input = gr.Textbox(label="Enter an object name (e.g., car)",
112
  placeholder="Enter an object name",
113
  lines=1)
114
 
@@ -116,10 +117,11 @@ def create_gradio_interface():
116
  generate_button = gr.Button("Generate Evolution")
117
 
118
  # Gradio Gallery component to display the images
119
- image_gallery = gr.Gallery(label="Generated Images", show_label=True, columns=3, rows=1)
 
120
 
121
  # Output for the generated GIF
122
- gif_output = gr.Image(label="Generated GIF", show_label=True)
123
 
124
  # Set the action when the button is clicked
125
  generate_button.click(fn=generate_object_history, inputs=[object_name_input], outputs=[image_gallery, gif_output])
@@ -130,4 +132,4 @@ def create_gradio_interface():
130
  demo = create_gradio_interface()
131
 
132
  # To make it permanent and hosted, we can use Gradio's 'share' argument or host it on a server.
133
- demo.launch(share=True)
 
82
  agent = ReactCodeAgent(tools=[image_generation_tool, search_tool], llm_engine=llm_engine)
83
 
84
 
85
+
86
+ # Paths to the precomputed files
87
+ default_images = [
88
+ ("car_past.png", "Car - Past"),
89
+ ("car_present.png", "Car - Present"),
90
+ ("car_future.png", "Car - Future")
91
+ ]
92
+ default_gif_path = "car_evolution.gif"
93
 
94
  # Gradio interface
95
  def create_gradio_interface():
 
99
  # Add a section for instructions
100
  gr.Markdown("""
101
  ## Welcome to the Object Evolution Generator!
 
102
  This app allows you to generate visualizations of how an object, like a bicycle or a car, may have evolved over time.
103
  It generates images of the object in the past, present, and future based on your input.
104
+
105
+ ### Default Example: Evolution of a Car
106
+ Below, you can see a precomputed example of a "car" evolution. Enter another object to generate its evolution.
 
 
 
 
 
107
  """)
108
 
109
  with gr.Row():
110
  with gr.Column():
111
  # Textbox for user to input an object name
112
+ object_name_input = gr.Textbox(label="Enter an object name (e.g., bicycle, phone)",
113
  placeholder="Enter an object name",
114
  lines=1)
115
 
 
117
  generate_button = gr.Button("Generate Evolution")
118
 
119
  # Gradio Gallery component to display the images
120
+ image_gallery = gr.Gallery(label="Generated Images", show_label=True, columns=3, rows=1,
121
+ value=default_images)
122
 
123
  # Output for the generated GIF
124
+ gif_output = gr.Image(label="Generated GIF", show_label=True, value=default_gif_path)
125
 
126
  # Set the action when the button is clicked
127
  generate_button.click(fn=generate_object_history, inputs=[object_name_input], outputs=[image_gallery, gif_output])
 
132
  demo = create_gradio_interface()
133
 
134
  # To make it permanent and hosted, we can use Gradio's 'share' argument or host it on a server.
135
+ demo.launch(share=True)