Mateo Fidabel commited on
Commit
892096a
1 Parent(s): 3804b82

Added more examples, moved some things

Browse files
app.py CHANGED
@@ -23,12 +23,21 @@ p_params = replicate(params)
23
 
24
  # Description
25
  title = "# 🧨 ControlNet on Segment Anything 🤗"
26
- description = "This is a demo on ControlNet based on Segment Anything"
 
 
 
 
 
 
 
 
 
 
27
 
28
- examples = [["a modern main room of a house", "low quality", "condition_image_1.png", 50, 4, 4]]
29
 
30
  # Inference Function
31
- def infer(prompts, negative_prompts, image, num_inference_steps, seed, num_samples):
32
  rng = jax.random.PRNGKey(int(seed))
33
  num_inference_steps = int(num_inference_steps)
34
  image = Image.fromarray(image, mode="RGB")
@@ -71,10 +80,12 @@ with gr.Blocks(css="h1 { text-align: center }") as demo:
71
 
72
  # Images
73
  with gr.Row(variant="panel"):
74
- cond_img = gr.Image(label="Input")\
75
- .style(height=400)
76
- output = gr.Gallery(label="Generated images")\
77
- .style(height="auto", rows=[2], columns=[1, 2])
 
 
78
 
79
  # Submit & Clear
80
  with gr.Row():
@@ -85,14 +96,15 @@ with gr.Blocks(css="h1 { text-align: center }") as demo:
85
  with gr.Column():
86
  with gr.Accordion("Advanced options", open=False):
87
  num_steps = gr.Slider(10, 60, 50, step=1, label="Steps")
88
- seed = gr.Slider(0, 1024, 0, step=1, label="Seed")
89
  num_samples = gr.Slider(1, 4, 4, step=1, label="Nº Samples")
90
 
91
- submit = gr.Button("Submit")
 
92
 
93
  # Examples
94
  gr.Examples(examples=examples,
95
- inputs=[prompt, negative_prompt, cond_img, num_steps, seed, num_samples],
96
  outputs=output,
97
  fn=infer,
98
  cache_examples=True)
 
23
 
24
  # Description
25
  title = "# 🧨 ControlNet on Segment Anything 🤗"
26
+ description = """This is a demo on 🧨 ControlNet based on Meta's [Segment Anything Model](https://segment-anything.com/).
27
+
28
+ Upload a Segment Anything Segmentation Map, write a prompt, and generate images 🤗 This demo is still Work in Progress, so don't expect it to work well for now !!
29
+
30
+
31
+ Test some of the examples below to give it a try ⬇️
32
+ """
33
+
34
+ examples = [["a modern main room of a house", "low quality", "examples/condition_image_1.png"],
35
+ ["new york buildings, Vincent Van Gogh starry night ", "low quality, monochrome", "examples/condition_image_2.png"],
36
+ ["contemporary living room, high quality, 4k, realistic", "low quality, monochrome, low res", "examples/condition_image_3.png"]]
37
 
 
38
 
39
  # Inference Function
40
+ def infer(prompts, negative_prompts, image, num_inference_steps = 50, seed = 4, num_samples = 4):
41
  rng = jax.random.PRNGKey(int(seed))
42
  num_inference_steps = int(num_inference_steps)
43
  image = Image.fromarray(image, mode="RGB")
 
80
 
81
  # Images
82
  with gr.Row(variant="panel"):
83
+ with gr.Column(scale=2):
84
+ cond_img = gr.Image(label="Input")\
85
+ .style(height=200)
86
+ with gr.Column(scale=1):
87
+ output = gr.Gallery(label="Generated images")\
88
+ .style(height=200, rows=[2], columns=[1, 2], object_fit="contain")
89
 
90
  # Submit & Clear
91
  with gr.Row():
 
96
  with gr.Column():
97
  with gr.Accordion("Advanced options", open=False):
98
  num_steps = gr.Slider(10, 60, 50, step=1, label="Steps")
99
+ seed = gr.Slider(0, 1024, 4, step=1, label="Seed")
100
  num_samples = gr.Slider(1, 4, 4, step=1, label="Nº Samples")
101
 
102
+ submit = gr.Button("Generate")
103
+ # TODO: Download Button
104
 
105
  # Examples
106
  gr.Examples(examples=examples,
107
+ inputs=[prompt, negative_prompt, cond_img],
108
  outputs=output,
109
  fn=infer,
110
  cache_examples=True)
condition_image_1.png → examples/condition_image_1.png RENAMED
File without changes
examples/condition_image_2.png ADDED
examples/condition_image_3.png ADDED