Spaces:
Running
Running
Commit
·
099a349
1
Parent(s):
76e4562
revert
Browse files
app.py
CHANGED
@@ -35,6 +35,27 @@ def encode_image(image_path):
|
|
35 |
return base64.b64encode(image_file.read()).decode('utf-8')
|
36 |
|
37 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
@spaces.GPU #[uncomment to use ZeroGPU]
|
39 |
def generate_description_fn(
|
40 |
image,
|
@@ -54,7 +75,7 @@ def generate_description_fn(
|
|
54 |
{
|
55 |
"type": "text",
|
56 |
"text": """
|
57 |
-
I want you to imagine how the
|
58 |
|
59 |
The style of the result should look somewhat like the following example:
|
60 |
The technical flat sketch of the dress would depict a midi-length, off-the-shoulder design with a smocked bodice and short puff sleeves that have elasticized cuffs. The elastic neckline sits straight across the chest and back, ensuring a secure fit. The bodice transitions into a flowy, tiered skirt with three evenly spaced gathered panels, creating soft volume. The back view mirrors the front, maintaining the smocked fit and tiered skirt without visible closures, suggesting a pullover style. Elasticized areas would be marked with textured lines, while the gathers and drape would be indicated through subtle curved strokes, ensuring clarity in construction details.
|
@@ -107,57 +128,8 @@ with gr.Blocks(css=css) as demo:
|
|
107 |
|
108 |
result = gr.Image(label="Result", show_label=False)
|
109 |
|
110 |
-
|
111 |
-
|
112 |
-
label="Negative prompt",
|
113 |
-
max_lines=1,
|
114 |
-
placeholder="Enter a negative prompt",
|
115 |
-
visible=False,
|
116 |
-
)
|
117 |
-
|
118 |
-
seed = gr.Slider(
|
119 |
-
label="Seed",
|
120 |
-
minimum=0,
|
121 |
-
maximum=MAX_SEED,
|
122 |
-
step=1,
|
123 |
-
value=0,
|
124 |
-
)
|
125 |
-
|
126 |
-
randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
|
127 |
-
|
128 |
-
with gr.Row():
|
129 |
-
width = gr.Slider(
|
130 |
-
label="Width",
|
131 |
-
minimum=256,
|
132 |
-
maximum=MAX_IMAGE_SIZE,
|
133 |
-
step=32,
|
134 |
-
value=1024, # Replace with defaults that work for your model
|
135 |
-
)
|
136 |
-
|
137 |
-
height = gr.Slider(
|
138 |
-
label="Height",
|
139 |
-
minimum=256,
|
140 |
-
maximum=MAX_IMAGE_SIZE,
|
141 |
-
step=32,
|
142 |
-
value=1024, # Replace with defaults that work for your model
|
143 |
-
)
|
144 |
-
|
145 |
-
with gr.Row():
|
146 |
-
guidance_scale = gr.Slider(
|
147 |
-
label="Guidance scale",
|
148 |
-
minimum=0.0,
|
149 |
-
maximum=10.0,
|
150 |
-
step=0.1,
|
151 |
-
value=0.0, # Replace with defaults that work for your model
|
152 |
-
)
|
153 |
-
|
154 |
-
num_inference_steps = gr.Slider(
|
155 |
-
label="Number of inference steps",
|
156 |
-
minimum=1,
|
157 |
-
maximum=50,
|
158 |
-
step=1,
|
159 |
-
value=2, # Replace with defaults that work for your model
|
160 |
-
)
|
161 |
|
162 |
gr.on(
|
163 |
triggers=[generate_button.click],
|
|
|
35 |
return base64.b64encode(image_file.read()).decode('utf-8')
|
36 |
|
37 |
|
38 |
+
@spaces.GPU #[uncomment to use ZeroGPU]
|
39 |
+
def infer(
|
40 |
+
prompt,
|
41 |
+
progress=gr.Progress(track_tqdm=True),
|
42 |
+
):
|
43 |
+
# seed = random.randint(0, MAX_SEED)
|
44 |
+
|
45 |
+
# generator = torch.Generator().manual_seed(seed)
|
46 |
+
|
47 |
+
image = pipe(
|
48 |
+
prompt=prompt,
|
49 |
+
guidance_scale=0.,
|
50 |
+
num_inference_steps=4,
|
51 |
+
width=1420,
|
52 |
+
height=1080,
|
53 |
+
max_sequence_length=256,
|
54 |
+
|
55 |
+
).images[0]
|
56 |
+
|
57 |
+
return image
|
58 |
+
|
59 |
@spaces.GPU #[uncomment to use ZeroGPU]
|
60 |
def generate_description_fn(
|
61 |
image,
|
|
|
75 |
{
|
76 |
"type": "text",
|
77 |
"text": """
|
78 |
+
I want you to imagine how the technical flat sketch of the garment you see in the picture would look like, both front and back descriptions are mandatory, and describe it to me in rich details, in one paragraph. Don't add any additional comment.
|
79 |
|
80 |
The style of the result should look somewhat like the following example:
|
81 |
The technical flat sketch of the dress would depict a midi-length, off-the-shoulder design with a smocked bodice and short puff sleeves that have elasticized cuffs. The elastic neckline sits straight across the chest and back, ensuring a secure fit. The bodice transitions into a flowy, tiered skirt with three evenly spaced gathered panels, creating soft volume. The back view mirrors the front, maintaining the smocked fit and tiered skirt without visible closures, suggesting a pullover style. Elasticized areas would be marked with textured lines, while the gathers and drape would be indicated through subtle curved strokes, ensuring clarity in construction details.
|
|
|
128 |
|
129 |
result = gr.Image(label="Result", show_label=False)
|
130 |
|
131 |
+
gr.Markdown("## Description of the garment:")
|
132 |
+
generated_prompt = gr.Markdown("")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
133 |
|
134 |
gr.on(
|
135 |
triggers=[generate_button.click],
|