Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -12,7 +12,31 @@ uid = uuid.uuid4()
|
|
12 |
|
13 |
#token_self = os.environ['HF_TOKEN']
|
14 |
|
15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
def slide_fn(val):
|
18 |
im =(f'tmpim22-{uid}.png')
|
@@ -394,6 +418,18 @@ def up_c(im,c_slider):
|
|
394 |
img1.save(f'tmpim22-{uid}.png')
|
395 |
out = slide_fn(c_slider)
|
396 |
return out
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
397 |
with gr.Blocks() as build_app:
|
398 |
gr.Markdown("""<center><h1>Interactive Twitter Card Builder</h1></center>""")
|
399 |
|
@@ -434,23 +470,28 @@ with gr.Blocks() as build_app:
|
|
434 |
with gr.Row():
|
435 |
def_im = gr.Button("Load Default Image")
|
436 |
gen_im = gr.Button("Generate Image")
|
437 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
438 |
c_image=gr.Image(label="Cropped Image", type="filepath",interactive=False)
|
439 |
c_slider=gr.Slider(0,220,value=0,step=1,label="Adjust Vertical Crop")
|
440 |
c_upbtn=gr.Button("Update Crop")
|
441 |
with gr.Tab("Build"):
|
442 |
-
|
443 |
-
build_button = gr.Button("Build")
|
444 |
-
gr.Column()
|
445 |
output_html = gr.HTML("""""")
|
446 |
with gr.Tab("Download"):
|
447 |
-
|
448 |
-
dl_button = gr.Button("Download")
|
449 |
-
gr.Column()
|
450 |
files_out = gr.Files()
|
451 |
gr.Column(scale=1)
|
452 |
|
453 |
-
|
|
|
|
|
454 |
t_image.change(up_c,[t_image,c_slider],c_image)
|
455 |
c_upbtn.click(slide_fn,c_slider,c_image)
|
456 |
build_button.click(build_space,[t_name,t_space,t_title,t_description,t_redirect,t_image,t_image_url,option_token],output_html)
|
|
|
12 |
|
13 |
#token_self = os.environ['HF_TOKEN']
|
14 |
|
15 |
+
models =[
|
16 |
+
"",
|
17 |
+
"CompVis/stable-diffusion-v1-4",
|
18 |
+
"runwayml/stable-diffusion-v1-5",
|
19 |
+
"prompthero/openjourney",
|
20 |
+
"stabilityai/stable-diffusion-2-1",
|
21 |
+
"stabilityai/stable-diffusion-2-1-base",
|
22 |
+
"SG161222/Realistic_Vision_V1.4",
|
23 |
+
"Linaqruf/anything-v3.0",
|
24 |
+
"eimiss/EimisAnimeDiffusion_1.0v",
|
25 |
+
"nitrosocke/Nitro-Diffusion",
|
26 |
+
"wavymulder/portraitplus",
|
27 |
+
"22h/vintedois-diffusion-v0-1",
|
28 |
+
"dreamlike-art/dreamlike-photoreal-2.0",
|
29 |
+
"dreamlike-art/dreamlike-diffusion-1.0",
|
30 |
+
"wavymulder/Analog-Diffusion",
|
31 |
+
"nitrosocke/redshift-diffusion",
|
32 |
+
"claudfuen/photorealistic-fuen-v1",
|
33 |
+
"prompthero/openjourney-v2",
|
34 |
+
"johnslegers/epic-diffusion",
|
35 |
+
"nitrosocke/Arcane-Diffusion",
|
36 |
+
"darkstorm2150/Protogen_x5.8_Official_Release",
|
37 |
+
|
38 |
+
]
|
39 |
+
current_model=models[5]
|
40 |
|
41 |
def slide_fn(val):
|
42 |
im =(f'tmpim22-{uid}.png')
|
|
|
418 |
img1.save(f'tmpim22-{uid}.png')
|
419 |
out = slide_fn(c_slider)
|
420 |
return out
|
421 |
+
|
422 |
+
text_gen=gr.Interface.load("spaces/Omnibus/MagicPrompt-Stable-Diffusion_link",live=True, preprocess=True)
|
423 |
+
im_gen=gr.Interface.load("spaces/Omnibus/Diffusionator-mod")
|
424 |
+
def get_prompts(prompt_text):
|
425 |
+
gen=text_gen(prompt_text)
|
426 |
+
return gen
|
427 |
+
|
428 |
+
def gen_im(prompt,model_choice,count=1):
|
429 |
+
out = im_gen(prompt,model_choice,count)
|
430 |
+
return out
|
431 |
+
|
432 |
+
|
433 |
with gr.Blocks() as build_app:
|
434 |
gr.Markdown("""<center><h1>Interactive Twitter Card Builder</h1></center>""")
|
435 |
|
|
|
470 |
with gr.Row():
|
471 |
def_im = gr.Button("Load Default Image")
|
472 |
gen_im = gr.Button("Generate Image")
|
473 |
+
with gr.Accordion("Generated Image Controls"):
|
474 |
+
with gr.Row():
|
475 |
+
prompt_input=gr.Textbox("Prompt")
|
476 |
+
model_name1 = gr.Dropdown(show_label=False, choices=[m for m in models], type="index", value=current_model, interactive=True)
|
477 |
+
with gr.Row():
|
478 |
+
magic_btn=gr.Button("Magic Prompt")
|
479 |
+
gen_btn=gr.Button("Generate Images")
|
480 |
+
gen_im_out=gr.Gallery()
|
481 |
c_image=gr.Image(label="Cropped Image", type="filepath",interactive=False)
|
482 |
c_slider=gr.Slider(0,220,value=0,step=1,label="Adjust Vertical Crop")
|
483 |
c_upbtn=gr.Button("Update Crop")
|
484 |
with gr.Tab("Build"):
|
485 |
+
build_button = gr.Button("Build")
|
|
|
|
|
486 |
output_html = gr.HTML("""""")
|
487 |
with gr.Tab("Download"):
|
488 |
+
dl_button = gr.Button("Download")
|
|
|
|
|
489 |
files_out = gr.Files()
|
490 |
gr.Column(scale=1)
|
491 |
|
492 |
+
magic_btn.click(get_prompts,prompt_input,prompt_input)
|
493 |
+
gen_btn.click(gen_im,prompt_input,gen_im_out)
|
494 |
+
|
495 |
t_image.change(up_c,[t_image,c_slider],c_image)
|
496 |
c_upbtn.click(slide_fn,c_slider,c_image)
|
497 |
build_button.click(build_space,[t_name,t_space,t_title,t_description,t_redirect,t_image,t_image_url,option_token],output_html)
|