Spaces:
Running
Running
Yaron Koresh
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -21,17 +21,16 @@ from diffusers.utils import load_image
|
|
21 |
#import jax
|
22 |
#import jax.numpy as jnp
|
23 |
|
24 |
-
os.environ["GRADIO_SERVER_PORT"]="7860"
|
25 |
-
|
26 |
def port_inc():
|
27 |
-
|
|
|
|
|
|
|
|
|
28 |
|
29 |
def init_pool():
|
30 |
port_inc()
|
31 |
|
32 |
-
_dynamo.config.suppress_errors = True
|
33 |
-
mp.set_start_method("spawn", force=True)
|
34 |
-
|
35 |
#pipe = DiffusionPipeline.from_pretrained("black-forest-labs/FLUX.1-schnell", torch_dtype=torch.bfloat16, token=os.getenv("hf_token")).to(device)
|
36 |
#pipe2 = StableDiffusionXLImg2ImgPipeline.from_pretrained("stabilityai/stable-diffusion-xl-refiner-1.0", torch_dtype=torch.float16, variant="fp16", use_safetensors=True).to(device)
|
37 |
#pipe2.unet = torch.compile(pipe2.unet, mode="reduce-overhead", fullgraph=True)
|
@@ -209,32 +208,38 @@ function custom(){
|
|
209 |
}
|
210 |
"""
|
211 |
|
212 |
-
|
|
|
|
|
|
|
|
|
213 |
result = []
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
|
|
|
|
|
21 |
#import jax
|
22 |
#import jax.numpy as jnp
|
23 |
|
|
|
|
|
24 |
def port_inc():
|
25 |
+
env = os.getenv("CUSTOM_PORT")
|
26 |
+
if env == None:
|
27 |
+
os.environ["CUSTOM_PORT"]="8000"
|
28 |
+
else:
|
29 |
+
os.environ["CUSTOM_PORT"]=str(int(env)+1)
|
30 |
|
31 |
def init_pool():
|
32 |
port_inc()
|
33 |
|
|
|
|
|
|
|
34 |
#pipe = DiffusionPipeline.from_pretrained("black-forest-labs/FLUX.1-schnell", torch_dtype=torch.bfloat16, token=os.getenv("hf_token")).to(device)
|
35 |
#pipe2 = StableDiffusionXLImg2ImgPipeline.from_pretrained("stabilityai/stable-diffusion-xl-refiner-1.0", torch_dtype=torch.float16, variant="fp16", use_safetensors=True).to(device)
|
36 |
#pipe2.unet = torch.compile(pipe2.unet, mode="reduce-overhead", fullgraph=True)
|
|
|
208 |
}
|
209 |
"""
|
210 |
|
211 |
+
if __name__ == "__main__":
|
212 |
+
|
213 |
+
port_inc()
|
214 |
+
_dynamo.config.suppress_errors = True
|
215 |
+
mp.set_start_method("spawn", force=True)
|
216 |
result = []
|
217 |
+
|
218 |
+
with gr.Blocks(theme=gr.themes.Soft(),css=css,js=js) as demo:
|
219 |
+
with gr.Column(elem_id="col-container"):
|
220 |
+
gr.Markdown(f"""
|
221 |
+
# MULTI-LANGUAGE IMAGE GENERATOR
|
222 |
+
""")
|
223 |
+
with gr.Row():
|
224 |
+
prompt = gr.Textbox(
|
225 |
+
elem_id="prompt",
|
226 |
+
placeholder="INCLUDE",
|
227 |
+
container=False,
|
228 |
+
max_lines=1
|
229 |
+
)
|
230 |
+
with gr.Row():
|
231 |
+
prompt2 = gr.Textbox(
|
232 |
+
elem_id="prompt2",
|
233 |
+
placeholder="EXCLUDE",
|
234 |
+
container=False,
|
235 |
+
max_lines=1
|
236 |
+
)
|
237 |
+
with gr.Row():
|
238 |
+
run_button = gr.Button("START",elem_classes="btn",scale=0)
|
239 |
+
with gr.Row():
|
240 |
+
result.append(gr.Image(interactive=False,elem_classes="image-container", label="Result", show_label=False, type='filepath', show_share_button=False))
|
241 |
+
result.append(gr.Image(interactive=False,elem_classes="image-container", label="Result", show_label=False, type='filepath', show_share_button=False))
|
242 |
+
result.append(gr.Image(interactive=False,elem_classes="image-container", label="Result", show_label=False, type='filepath', show_share_button=False))
|
243 |
+
|
244 |
+
run_button.click(fn=main,inputs=[prompt,prompt2],outputs=result)
|
245 |
+
demo.queue().launch(server_port=os.getenv("CUSTOM_PORT"))
|