AmitIsraeli commited on
Commit
8d1279d
1 Parent(s): 8993bc0

add examples

Browse files
app.py CHANGED
@@ -114,7 +114,6 @@ class InrenceTextVAR(nn.Module):
114
 
115
 
116
  if __name__ == '__main__':
117
-
118
  # Initialize the model
119
  checkpoint = 'VARtext_v1.pth' # Replace with your actual checkpoint path
120
  device = 'cpu' if not torch.cuda.is_available() else 'cuda'
@@ -123,6 +122,7 @@ if __name__ == '__main__':
123
  model.load_state_dict(state_dict)
124
  model.to(device)
125
 
 
126
  def generate_image_gradio(text, beta=1.0, seed=None, more_smooth=False, top_k=0, top_p=0.9):
127
  print(f"Generating image for text: {text}\n"
128
  f"beta: {beta}\n"
@@ -133,8 +133,9 @@ if __name__ == '__main__':
133
  image = model.generate_image(text, beta=beta, seed=seed, more_smooth=more_smooth, top_k=int(top_k), top_p=top_p)
134
  return image
135
 
 
136
  with gr.Blocks() as demo:
137
- gr.Markdown("# Text to Image/Video Generator")
138
  with gr.Tab("Generate Image"):
139
  text_input = gr.Textbox(label="Input Text")
140
  beta_input = gr.Slider(label="Beta", minimum=0.0, maximum=2.5, step=0.05, value=1.0)
@@ -150,4 +151,16 @@ if __name__ == '__main__':
150
  outputs=image_output
151
  )
152
 
153
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
114
 
115
 
116
  if __name__ == '__main__':
 
117
  # Initialize the model
118
  checkpoint = 'VARtext_v1.pth' # Replace with your actual checkpoint path
119
  device = 'cpu' if not torch.cuda.is_available() else 'cuda'
 
122
  model.load_state_dict(state_dict)
123
  model.to(device)
124
 
125
+
126
  def generate_image_gradio(text, beta=1.0, seed=None, more_smooth=False, top_k=0, top_p=0.9):
127
  print(f"Generating image for text: {text}\n"
128
  f"beta: {beta}\n"
 
133
  image = model.generate_image(text, beta=beta, seed=seed, more_smooth=more_smooth, top_k=int(top_k), top_p=top_p)
134
  return image
135
 
136
+
137
  with gr.Blocks() as demo:
138
+ gr.Markdown("# PopYou2-VAR")
139
  with gr.Tab("Generate Image"):
140
  text_input = gr.Textbox(label="Input Text")
141
  beta_input = gr.Slider(label="Beta", minimum=0.0, maximum=2.5, step=0.05, value=1.0)
 
151
  outputs=image_output
152
  )
153
 
154
+ gr.Markdown("### Examples")
155
+ with gr.Row():
156
+ example1_text = gr.Textbox(label="Example 1", value="a funko pop figure of a yellow robot tom cruise with headphones on a white background", interactive=False)
157
+ example1_image = gr.Image(label="Generated Image 1", value="examples/tom_cruise_robot.png") # Replace with the actual path
158
+ with gr.Row():
159
+ example2_text = gr.Textbox(label="Example 2", value="a funko pop figure of a alien Scarlett Johansson holding a shield on a white background", interactive=False)
160
+ example2_image = gr.Image(label="Generated Image 2", value="examples/alien_Scarlett_Johansson.png") # Replace with the actual path
161
+ with gr.Row():
162
+ example3_text = gr.Textbox(label="Example 3", value="a funko pop figure of a woman with a hat and a pink long hair and blue dress on a white background", interactive=False)
163
+ example3_image = gr.Image(label="Generated Image 3", value="examples/woman_pink.png") # Replace with the actual path
164
+
165
+ demo.launch()
166
+
examples/alien_Scarlett_Johansson.png ADDED
examples/tom_cruise_robot.png ADDED
examples/woman_pink.png ADDED