Spaces:
Runtime error
Runtime error
Commit
·
66303da
1
Parent(s):
4fe873f
remove unused functions
Browse files
app.py
CHANGED
|
@@ -35,27 +35,6 @@ 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 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,
|
|
@@ -128,8 +107,59 @@ with gr.Blocks(css=css) as demo:
|
|
| 128 |
|
| 129 |
result = gr.Image(label="Result", show_label=False)
|
| 130 |
|
| 131 |
-
gr.
|
| 132 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 133 |
|
| 134 |
gr.on(
|
| 135 |
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 generate_description_fn(
|
| 40 |
image,
|
|
|
|
| 107 |
|
| 108 |
result = gr.Image(label="Result", show_label=False)
|
| 109 |
|
| 110 |
+
with gr.Accordion("Advanced Settings", open=False):
|
| 111 |
+
negative_prompt = gr.Text(
|
| 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.Examples(examples=examples, inputs=[prompt])
|
| 163 |
|
| 164 |
gr.on(
|
| 165 |
triggers=[generate_button.click],
|