jutaporn37678 commited on
Commit
97a76cc
1 Parent(s): a58c9d9

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -43
app.py DELETED
@@ -1,43 +0,0 @@
1
- import gradio as gr
2
- import os
3
-
4
- title="Stable Diffusion v2.0 Converted"
5
-
6
- description="""
7
- <p style="text-align:center;">
8
- Stable Diffusion 2 uses OpenCLIP ViT-H model trained on LAION dataset so it knows different things than the OpenAI ViT-L we're all used to prompting.
9
- <br />This demo converts a v1.x stable diffusion to a stable diffusion 2.x,
10
- <br />by generating an image through <a href="https://huggingface.co/runwayml/stable-diffusion-v1-5" target="_blank">RunwayML Stable Diffusion 1.5</a>, then Interrogate the resulting image through <a href="https://huggingface.co/spaces/fffiloni/CLIP-Interrogator-2" target="_blank">CLIP Interrogator 2</a> to give you a Stable Diffusion 2 equivalent prompt.
11
- </p>
12
- """
13
-
14
- stable_diffusion = gr.Blocks.load(name="spaces/runwayml/stable-diffusion-v1-5")
15
- clip_interrogator_2 = gr.Blocks.load(name="spaces/fffiloni/CLIP-Interrogator-2")
16
-
17
- def get_images(prompt):
18
- gallery_dir = stable_diffusion(prompt, fn_index=2)
19
- img_results = [os.path.join(gallery_dir, img) for img in os.listdir(gallery_dir)]
20
- return img_results[0]
21
-
22
- def get_new_prompt(img, mode):
23
- interrogate = clip_interrogator_2(img, mode, 12, api_name="clipi2")
24
- return interrogate
25
-
26
- def infer(prompt, mode):
27
- img = get_images(prompt)
28
- result = get_new_prompt(img, mode)
29
- return result[0]
30
-
31
- prompt_input = gr.Textbox(lines=4, label="Input Stable Diffusion v2.0 converted")
32
- mode_input = gr.Radio(['best', 'v1', '1'], v2='2', v3='3')
33
- prompt_output = gr.Textbox(lines=4, label="Converted.x Stable Diffusion v2.0 converted")
34
-
35
- examples=[
36
- ["house tree a city weapons and uniform, serious, finely detailed, made by wlop, boichi, ilya kuvshinov, full body portrait, illustration, grass, sunny, sky, anime, side view, perfect anime face, detailed face, zoomed out, smooth","fast"],
37
- ["city blue cockatiel riding on the rings of saturn wearing a propeller hat, fantasy, intricate, elegant, highly detailed, digital painting, artstation, concept art, smooth, sharp focus, illustration, art by artgerm and greg rutkowski and alphonse mucha ","classic"],
38
- ["painting, view from inside edward hopper's painting nighthawks, of a group of werebears robbing a bank, foggy ","best"]
39
- ]
40
-
41
- demo=gr.Interface(fn=infer, inputs=[prompt_input,mode_input], outputs=[prompt_output],title=title,description=description,examples=examples)
42
- demo.queue(max_size=10,concurrency_count=20)
43
- demo.launch(enable_queue=True)