NikhilJoson commited on
Commit
be84c5e
·
verified ·
1 Parent(s): 212bae8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -36
app.py CHANGED
@@ -28,11 +28,13 @@ def predict_clothing(images):
28
 
29
  output_texts = []
30
  for image in images:
 
31
  inputs = processor(image, input_text, add_special_tokens=False, return_tensors="pt").to(model.device)
32
  with torch.no_grad():
33
- output = model.generate(**inputs, max_new_tokens=30)
34
  output_texts.append(str(processor.decode(output[0])))
35
-
 
36
  return output_texts
37
 
38
 
@@ -127,41 +129,32 @@ with gr.Blocks() as demo:
127
  image_input_2 = gr.Image(label="Top-wear", type="filepath")
128
  image_input_3 = gr.Image(label="Bottom-wear", type="filepath")
129
 
130
- with gr.Column():
131
- # sliders
132
- height_input = gr.Slider(
133
- label="Height", minimum=128, maximum=2048, value=1024, step=16
134
- )
135
- width_input = gr.Slider(
136
- label="Width", minimum=128, maximum=2048, value=1024, step=16
137
- )
138
-
139
- # guidance_scale_input = gr.Slider(
140
- # label="Guidance Scale", minimum=1.0, maximum=5.0, value=2.5, step=0.1
141
- # )
142
-
143
- num_inference_steps = gr.Slider(
144
- label="Inference Steps", minimum=1, maximum=100, value=50, step=1
145
- )
146
 
147
- seed_input = gr.Slider(
148
- label="Seed", minimum=0, maximum=2147483647, value=42, step=1
149
- )
150
- randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
151
-
152
- with gr.Column():
153
- img_guidance_scale_input = gr.Slider(label="img_guidance_scale", minimum=1.0, maximum=2.0, value=1.6, step=0.1)
154
-
155
- max_input_image_size = gr.Slider(label="max_input_image_size", minimum=128, maximum=2048, value=1024, step=16)
156
-
157
- separate_cfg_infer = gr.Checkbox(
158
- label="separate_cfg_infer", info="Whether to use separate inference process for different guidance. This will reduce the memory cost.", value=True,)
159
-
160
- offload_model = gr.Checkbox(
161
- label="offload_model", info="Offload model to CPU, which will significantly reduce the memory cost but slow down the generation speed. You can cancel separate_cfg_infer and set offload_model=True. If both separate_cfg_infer and offload_model are True, further reduce the memory, but slowest generation", value=False,)
162
-
163
- use_input_image_size_as_output = gr.Checkbox(
164
- label="use_input_image_size_as_output", info="Automatically adjust the output image size to be same as input image size. For editing and controlnet task, it can make sure the output image has the same size as input image leading to better performance", value=False,)
165
 
166
  # generate
167
  generate_button = gr.Button("Generate Image")
 
28
 
29
  output_texts = []
30
  for image in images:
31
+ print(type(image))
32
  inputs = processor(image, input_text, add_special_tokens=False, return_tensors="pt").to(model.device)
33
  with torch.no_grad():
34
+ output = model.generate(**inputs, max_new_tokens=32)
35
  output_texts.append(str(processor.decode(output[0])))
36
+
37
+ print(output_texts)
38
  return output_texts
39
 
40
 
 
129
  image_input_2 = gr.Image(label="Top-wear", type="filepath")
130
  image_input_3 = gr.Image(label="Bottom-wear", type="filepath")
131
 
132
+ with gr.Row(equal_height=True):
133
+ with gr.Column():
134
+ # sliders
135
+ max_input_image_size = gr.Slider(label="max_input_image_size", minimum=128, maximum=2048, value=1024, step=16)
136
+
137
+ height_input = gr.Slider(label="Height", minimum=128, maximum=1024, value=512, step=16)
138
+ width_input = gr.Slider(label="Width", minimum=128, maximum=1024, value=512, step=16)
139
+
140
+ # guidance_scale_input = gr.Slider(label="Guidance Scale", minimum=1.0, maximum=5.0, value=2.5, step=0.1)
141
+
142
+ num_inference_steps = gr.Slider(label="Inference Steps", minimum=1, maximum=128, value=32, step=1)
143
+
144
+ seed_input = gr.Slider(label="Seed", minimum=0, maximum=2147483647, value=42, step=1)
145
+ randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
 
 
146
 
147
+ with gr.Column():
148
+ img_guidance_scale_input = gr.Slider(label="img_guidance_scale", minimum=1.0, maximum=2.0, value=1.6, step=0.1)
149
+
150
+ separate_cfg_infer = gr.Checkbox(
151
+ label="separate_cfg_infer", info="Whether to use separate inference process for different guidance. This will reduce the memory cost.", value=True,)
152
+
153
+ offload_model = gr.Checkbox(
154
+ label="offload_model", info="Offload model to CPU, which will significantly reduce the memory cost but slow down the generation speed. You can cancel separate_cfg_infer and set offload_model=True. If both separate_cfg_infer and offload_model are True, further reduce the memory, but slowest generation", value=False,)
155
+
156
+ use_input_image_size_as_output = gr.Checkbox(
157
+ label="use_input_image_size_as_output", info="Automatically adjust the output image size to be same as input image size. For editing and controlnet task, it can make sure the output image has the same size as input image leading to better performance", value=False,)
 
 
 
 
 
 
 
158
 
159
  # generate
160
  generate_button = gr.Button("Generate Image")