Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
import gradio as gr
|
2 |
import os
|
3 |
import random
|
4 |
-
from PIL import Image
|
5 |
import spaces
|
6 |
import torch
|
7 |
from transformers import MllamaForConditionalGeneration, AutoProcessor
|
8 |
from OmniGen import OmniGenPipeline
|
|
|
9 |
|
10 |
from huggingface_hub import login
|
11 |
Llama32V_HFtoken = os.getenv("Llama32V")
|
@@ -27,7 +27,8 @@ def predict_clothing(images):
|
|
27 |
input_text = processor.apply_chat_template(messages, add_generation_prompt=True)
|
28 |
|
29 |
output_texts = []
|
30 |
-
for
|
|
|
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():
|
@@ -129,32 +130,32 @@ with gr.Blocks() as demo:
|
|
129 |
image_input_2 = gr.Image(label="Top-wear", type="filepath")
|
130 |
image_input_3 = gr.Image(label="Bottom-wear", type="filepath")
|
131 |
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
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 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
|
|
|
|
|
|
|
|
|
|
158 |
|
159 |
# generate
|
160 |
generate_button = gr.Button("Generate Image")
|
|
|
1 |
import gradio as gr
|
2 |
import os
|
3 |
import random
|
|
|
4 |
import spaces
|
5 |
import torch
|
6 |
from transformers import MllamaForConditionalGeneration, AutoProcessor
|
7 |
from OmniGen import OmniGenPipeline
|
8 |
+
from PIL import Image
|
9 |
|
10 |
from huggingface_hub import login
|
11 |
Llama32V_HFtoken = os.getenv("Llama32V")
|
|
|
27 |
input_text = processor.apply_chat_template(messages, add_generation_prompt=True)
|
28 |
|
29 |
output_texts = []
|
30 |
+
for url in images:
|
31 |
+
image = Image.open(requests.get(url, stream=True).raw)
|
32 |
print(type(image))
|
33 |
inputs = processor(image, input_text, add_special_tokens=False, return_tensors="pt").to(model.device)
|
34 |
with torch.no_grad():
|
|
|
130 |
image_input_2 = gr.Image(label="Top-wear", type="filepath")
|
131 |
image_input_3 = gr.Image(label="Bottom-wear", type="filepath")
|
132 |
|
133 |
+
with gr.Row():
|
134 |
+
with gr.Column():
|
135 |
+
# sliders
|
136 |
+
max_input_image_size = gr.Slider(label="max_input_image_size", minimum=128, maximum=2048, value=1024, step=16)
|
137 |
+
|
138 |
+
height_input = gr.Slider(label="Height", minimum=128, maximum=1024, value=512, step=16)
|
139 |
+
width_input = gr.Slider(label="Width", minimum=128, maximum=1024, value=512, step=16)
|
140 |
+
|
141 |
+
# guidance_scale_input = gr.Slider(label="Guidance Scale", minimum=1.0, maximum=5.0, value=2.5, step=0.1)
|
|
|
|
|
|
|
|
|
|
|
142 |
|
143 |
+
num_inference_steps = gr.Slider(label="Inference Steps", minimum=1, maximum=128, value=32, step=1)
|
144 |
+
|
145 |
+
seed_input = gr.Slider(label="Seed", minimum=0, maximum=2147483647, value=42, step=1)
|
146 |
+
randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
|
147 |
+
|
148 |
+
with gr.Column():
|
149 |
+
img_guidance_scale_input = gr.Slider(label="img_guidance_scale", minimum=1.0, maximum=2.0, value=1.6, step=0.1)
|
150 |
+
|
151 |
+
separate_cfg_infer = gr.Checkbox(
|
152 |
+
label="separate_cfg_infer", info="Whether to use separate inference process for different guidance. This will reduce the memory cost.", value=True,)
|
153 |
+
|
154 |
+
offload_model = gr.Checkbox(
|
155 |
+
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,)
|
156 |
+
|
157 |
+
use_input_image_size_as_output = gr.Checkbox(
|
158 |
+
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,)
|
159 |
|
160 |
# generate
|
161 |
generate_button = gr.Button("Generate Image")
|