AMfeta99 commited on
Commit
2200a21
·
verified ·
1 Parent(s): e3a4c52

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -15
app.py CHANGED
@@ -6,7 +6,6 @@ from smolagents import DuckDuckGoSearchTool, Tool
6
  from diffusers import DiffusionPipeline
7
  import torch
8
  from smolagents import OpenAIServerModel
9
-
10
  import os
11
  from huggingface_hub import login
12
 
@@ -60,7 +59,7 @@ def add_label_to_image(image, label):
60
 
61
  def plot_and_save_agent_image(agent_image, label, save_path=None):
62
  #pil_image = agent_image.to_raw()
63
- pil_image=agent_image
64
  labeled_image = add_label_to_image(pil_image, label)
65
  #labeled_image.show()
66
  if save_path:
@@ -78,6 +77,11 @@ def generate_prompts_for_object(object_name):
78
  }
79
 
80
 
 
 
 
 
 
81
  image_generation_tool = Tool.from_space(
82
  #"KingNish/Realtime-FLUX",
83
  "black-forest-labs/FLUX.1-schnell",
@@ -86,15 +90,10 @@ image_generation_tool = Tool.from_space(
86
  description="Generate an image from a prompt"
87
  )
88
 
89
-
90
- # =========================================================
91
- # Tool and Agent Initialization
92
- # =========================================================
93
-
94
  search_tool = DuckDuckGoSearchTool()
95
  #llm_engine = InferenceClientModel("Qwen/Qwen2.5-72B-Instruct")
96
 
97
- #llm_engine = InferenceClientModel("Qwen/Qwen2.5-Coder-32B-Instruct")
98
 
99
  # Inicialização do modelo OpenAI com smolagents
100
  llm_engine = OpenAIServerModel(
@@ -173,6 +172,7 @@ def generate_object_history(object_name):
173
  # Gradio Interface
174
  # =========================================================
175
 
 
176
  def create_gradio_interface():
177
  with gr.Blocks() as demo:
178
  gr.Markdown("# TimeMetamorphy: An Object Evolution Generator")
@@ -182,9 +182,9 @@ def create_gradio_interface():
182
  """)
183
 
184
  default_images = [
185
- "car_past.png",
186
- "car_present.png",
187
- "car_future.png"
188
  ]
189
  default_gif_path = "car_evolution.gif"
190
 
@@ -192,10 +192,10 @@ def create_gradio_interface():
192
  with gr.Column():
193
  object_name_input = gr.Textbox(label="Enter an object name", placeholder="e.g. bicycle, car, phone")
194
  generate_button = gr.Button("Generate Evolution")
195
- #image_gallery = gr.Gallery(label="Generated Images", columns=3, rows=1, value=default_images, type="filepath")
196
- #gif_output = gr.Image(label="Generated GIF", value=default_gif_path, type="filepath")
197
- image_gallery = gr.Gallery(label="Generated Images", columns=3, rows=1, type="filepath")
198
- gif_output = gr.Image(label="Generated GIF", type="filepath")
199
 
200
  generate_button.click(fn=generate_object_history, inputs=[object_name_input], outputs=[image_gallery, gif_output])
201
 
 
6
  from diffusers import DiffusionPipeline
7
  import torch
8
  from smolagents import OpenAIServerModel
 
9
  import os
10
  from huggingface_hub import login
11
 
 
59
 
60
  def plot_and_save_agent_image(agent_image, label, save_path=None):
61
  #pil_image = agent_image.to_raw()
62
+ pil_image = agent_image
63
  labeled_image = add_label_to_image(pil_image, label)
64
  #labeled_image.show()
65
  if save_path:
 
77
  }
78
 
79
 
80
+
81
+ # =========================================================
82
+ # Tool and Agent Initialization
83
+ # =========================================================
84
+
85
  image_generation_tool = Tool.from_space(
86
  #"KingNish/Realtime-FLUX",
87
  "black-forest-labs/FLUX.1-schnell",
 
90
  description="Generate an image from a prompt"
91
  )
92
 
 
 
 
 
 
93
  search_tool = DuckDuckGoSearchTool()
94
  #llm_engine = InferenceClientModel("Qwen/Qwen2.5-72B-Instruct")
95
 
96
+ llm_engine2 = InferenceClientModel("Qwen/Qwen2.5-Coder-32B-Instruct", provider="together")
97
 
98
  # Inicialização do modelo OpenAI com smolagents
99
  llm_engine = OpenAIServerModel(
 
172
  # Gradio Interface
173
  # =========================================================
174
 
175
+
176
  def create_gradio_interface():
177
  with gr.Blocks() as demo:
178
  gr.Markdown("# TimeMetamorphy: An Object Evolution Generator")
 
182
  """)
183
 
184
  default_images = [
185
+ "car_past2.png",
186
+ "car_present2.png",
187
+ "car_future2.png"
188
  ]
189
  default_gif_path = "car_evolution.gif"
190
 
 
192
  with gr.Column():
193
  object_name_input = gr.Textbox(label="Enter an object name", placeholder="e.g. bicycle, car, phone")
194
  generate_button = gr.Button("Generate Evolution")
195
+ image_gallery = gr.Gallery(label="Generated Images", columns=3, rows=1, value=default_images, type="filepath")
196
+ gif_output = gr.Image(label="Generated GIF", value=default_gif_path, type="filepath")
197
+ #image_gallery = gr.Gallery(label="Generated Images", columns=3, rows=1, type="filepath")
198
+ #gif_output = gr.Image(label="Generated GIF", type="filepath")
199
 
200
  generate_button.click(fn=generate_object_history, inputs=[object_name_input], outputs=[image_gallery, gif_output])
201