seawolf2357 commited on
Commit
80293de
โ€ข
1 Parent(s): a4093de

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -15
app.py CHANGED
@@ -6,6 +6,7 @@ import spaces
6
  from PIL import Image
7
  import requests
8
  from translatepy import Translator
 
9
 
10
  translator = Translator()
11
 
@@ -24,7 +25,7 @@ footer {
24
 
25
  JS = """function () {
26
  gradioURL = window.location.href
27
- if (!gradioURL.endswith('?__theme=dark')) {
28
  window.location.replace(gradioURL + '?__theme=dark');
29
  }
30
  }"""
@@ -54,34 +55,44 @@ def generate_image(
54
  prompt = str(translator.translate(prompt, 'English'))
55
 
56
  print(f'prompt:{prompt}')
57
-
58
- images = pipe(
 
 
 
59
  prompt,
60
  negative_prompt=negative,
61
  width=width,
62
  height=height,
63
  guidance_scale=scale,
64
  num_inference_steps=steps,
 
65
  ).images
66
 
67
- # ๋‘ ๊ฐœ์˜ ์ด๋ฏธ์ง€๋ฅผ ๋ณด์žฅํ•˜๊ธฐ ์œ„ํ•ด ์˜ˆ์™ธ ์ฒ˜๋ฆฌ
68
- if len(images) < 2:
69
- images += [images[0]] * (2 - len(images)) # ์ด๋ฏธ์ง€ ๋ณต์‚ฌ
 
 
 
 
 
 
70
 
71
- return images[0], images[1] # ๋‘ ์ด๋ฏธ์ง€๋ฅผ ๋ฐ˜ํ™˜
72
 
73
 
74
  examples = [
75
  "์•„๋ฆ„๋‹ค์šด 20์„ธ ํ•œ๊ตญ ์—ฌ์ž ๋ชจ๋ธ, 'ํ•œ๊ตญ ์—ฌ์ž๊ฐ€์ˆ˜ ์•„์ด์œ  ๋‹ฎ์€ ์–ผ๊ตด', ๊ฒ€์€์ƒ‰ ์งง์€ ๋‹จ๋ฐœ๋จธ๋ฆฌ, C์ปต ์‚ฌ์ด์ฆˆ์˜ ํฐ ๊ฐ€์Šด, ํฐ ๊ณจ๋ฐ˜, ๊ฐ€์ˆ˜ ์œ ๋‹ˆํผ, ๋ฐฐ๊ฒฝ ํฐ์ƒ‰, ์Šค๋งˆ์ผ ํ‘œ์ •, ๋ชจ๋ธ ํฌ์ฆˆ, ์ •๋ฉด ์‘์‹œ, ์ „์‹  ๋…ธ์ถœ, ์ดˆ๊ณ ํ•ด์ƒ๋„ ์‚ฌ์ง„",
76
  "์•„๋ฆ„๋‹ค์šด 20์„ธ ์˜๊ตญ ์—ฌ์ž ๋ชจ๋ธ, '์— ๋งˆ์™“์Šจ ๋‹ฎ์€ ์–ผ๊ตด', ๊ธˆ๋ฐœ ์งง์€ ๋‹จ๋ฐœ๋จธ๋ฆฌ, ์ด๋ธŒ๋‹ ๋“œ๋ ˆ์Šค, ๋ฐฐ๊ฒฝ ์‹œ์ƒ์‹, ์Šค๋งˆ์ผ ํ‘œ์ •, ๋ชจ๋ธ ํฌ์ฆˆ, ์ •๋ฉด ์‘์‹œ, ์ „์‹  ๋…ธ์ถœ, ์ดˆ๊ณ ํ•ด์ƒ๋„ ์‚ฌ์ง„",
77
  "์•„๋ฆ„๋‹ค์šด 20์„ธ ํ•œ๊ตญ ์—ฌ์ž ๋ชจ๋ธ, 'ํ•œ๊ตญ ์—ฌ์ž ์•„์ด๋Œ ๋‹ฎ์€ ์–ผ๊ตด', ๊ฒ€์€์ƒ‰ ์งง์€ ๋‹จ๋ฐœ๋จธ๋ฆฌ, ๋น„ํ‚ค๋‹ˆ ์ˆ˜์˜๋ณต, ๋ฐฐ๊ฒฝ ์ˆ˜์˜์žฅ, ์Šค๋งˆ์ผ ํ‘œ์ •, ๋ชจ๋ธ ํฌ์ฆˆ, ์ •๋ฉด ์‘์‹œ, ์ „์‹  ๋…ธ์ถœ, ์ดˆ๊ณ ํ•ด์ƒ๋„ ์‚ฌ์ง„",
78
- "์•„๋ฆ„๋‹ค์šด 23์„ธ ๋ฏธ๊ตญ ์—ฌ์ž ๋ชจ๋ธ, '์•ˆ์ ค๋ฆฌ๋‚˜ ์กธ๋ฆฌ ๋‹ฎ์€ ์–ผ๊ตด', ๊ฐˆ์ƒ‰ ๊ธด ์ƒ๋จธ๋ฆฌ, C์ปต ์‚ฌ์ด์ฆˆ์˜ ํฐ ๊ฐ€์Šด, ๋ฐฐ๊ฒฝ ์ŠคํŠœ๋””์˜ค, ์ง„์ง€ํ•œ ํ‘œ์ •, ์˜คํ”ผ์Šค ์œ ๋‹ˆํผ, ๋ชจ๋ธ ํฌ์ฆˆ, ์ •๋ฉด ์‘์‹œ, ์ดˆ๊ณ ํ•ด์ƒ๋„ ์‚ฌ์ง„",
79
- "์•„๋ฆ„๋‹ค์šด 18์„ธ ์ผ๋ณธ ์—ฌ์ž ๋ชจ๋ธ, '์œ ๋ช… ์—ฌ์ž ์˜ํ™” ๋ฐฐ์šฐ ๋‹ฎ์€ ์–ผ๊ตด', ๊ฒ€์€์ƒ‰ ์งง์€ ๋‹จ๋ฐœ๋จธ๋ฆฌ, ์Šค๋งˆ์ผ ํ‘œ์ •, ๊ต๋ณต ์œ ๋‹ˆํผ, ๋ฐฐ๊ฒฝ ํ•™๊ต ๊ต์‹ค, ๋ชจ๋ธ ํฌ์ฆˆ, ์ •๋ฉด ์‘์‹œ, ์ดˆ๊ณ ํ•ด์ƒ๋„ ์‚ฌ์ง„",
80
- "์•„๋ฆ„๋‹ค์šด 20์„ธ ๋ธŒ๋ผ์งˆ ์—ฌ์ž ๋ชจ๋ธ, '์œ ๋ช… ์—ฌ์ž ์˜ํ™” ๋ฐฐ์šฐ ๋‹ฎ์€ ์–ผ๊ตด', ๊ฒ€์€์ƒ‰ ์งง์€ ๋‹จ๋ฐœ๋จธ๋ฆฌ, C์ปต ์‚ฌ์ด์ฆˆ์˜ ํฐ ๊ฐ€์Šด, ํฐ ๊ณจ๋ฐ˜, ๊ฐ„ํ˜ธ์‚ฌ ์œ ๋‹ˆํผ, ๋ฐฐ๊ฒฝ ํฐ์ƒ‰, ์Šค๋งˆ์ผ ํ‘œ์ •, ๋ชจ๋ธ ํฌ์ฆˆ, ์ •๋ฉด ์‘์‹œ, ์ „์‹  ๋…ธ์ถœ, ์ดˆ๊ณ ํ•ด์ƒ๋„ ์‚ฌ์ง„",
81
- "์•„๋ฆ„๋‹ค์šด 20์„ธ ์Šค์›จ๋ด ์—ฌ์ž ๋ชจ๋ธ, '์œ ๋ช… ์—ฌ์ž ์˜ํ™” ๋ฐฐ์šฐ ๋‹ฎ์€ ์–ผ๊ตด', ๊ธˆ๋ฐœ ๊ธด ์ƒ๋จธ๋ฆฌ, C์ปต ์‚ฌ์ด์ฆˆ์˜ ํฐ ๊ฐ€์Šด, ํฐ ๊ณจ๋ฐ˜, ๋น„ํ‚ค๋‹ˆ ์ˆ˜์˜๋ณต, ๋ฐฐ๊ฒฝ ํ•ด๋ณ€๊ฐ€, ์Šค๋งˆ์ผ ํ‘œ์ •, ๋ชจ๋ธ ํฌ์ฆˆ, ์ •๋ฉด ์‘์‹œ, ์ดˆ๊ณ ํ•ด์ƒ๋„ ์‚ฌ์ง„",
82
- "์•„๋ฆ„๋‹ค์šด 18์„ธ ๋Ÿฌ์‹œ์•„ ์—ฌ์ž ๋ชจ๋ธ, '์œ ๋ช… ์—ฌ์ž ์˜ํ™” ๋ฐฐ์šฐ ๋‹ฎ์€ ์–ผ๊ตด', ๊ธˆ๋ฐœ ์งง์€ ๋‹จ๋ฐœ๋จธ๋ฆฌ, C์ปต ์‚ฌ์ด์ฆˆ์˜ ํฐ ๊ฐ€์Šด, ํฐ ๊ณจ๋ฐ˜, ๋น„ํ‚ค๋‹ˆ ์ˆ˜์˜๋ณต, ๋ฐฐ๊ฒฝ ์ˆ˜์˜์žฅ, ์—„์ˆ™ํ•œ ํ‘œ์ •, ๋ชจ๋ธ ํฌ์ฆˆ, ์ •๋ฉด ์‘์‹œ, ์ดˆ๊ณ ํ•ด์ƒ๋„ ์‚ฌ์ง„",
83
- "์•„๋ฆ„๋‹ค์šด 20์„ธ ํ”„๋ž‘์Šค ์—ฌ์ž ๋ชจ๋ธ, '์œ ๋ช… ์—ฌ์ž ์˜ํ™” ๋ฐฐ์šฐ ๋‹ฎ์€ ์–ผ๊ตด', ๊ฐˆ์ƒ‰ ์งง์€ ๋‹จ๋ฐœ๋จธ๋ฆฌ, C์ปต ์‚ฌ์ด์ฆˆ์˜ ํฐ ๊ฐ€์Šด, ํฐ ๊ณจ๋ฐ˜, ๋น„์ฆˆ๋‹ˆ์Šค ์ •์žฅ, ๋ฐฐ๊ฒฝ ์‚ฌ๋ฌด์‹ค, ํฌ๊ฒŒ ์›ƒ๋Š” ํ‘œ์ •, ๋ชจ๋ธ ํฌ์ฆˆ, ์ •๋ฉด ์‘์‹œ, ์ดˆ๊ณ ํ•ด์ƒ๋„ ์‚ฌ์ง„",
84
- "์•„๋ฆ„๋‹ค์šด 16์„ธ ์šฐํฌ๋ผ์ด๋‚˜ ์—ฌ์ž ๋ชจ๋ธ, '์œ ๋ช… ์—ฌ์ž ์˜ํ™” ๋ฐฐ์šฐ ๋‹ฎ์€ ์–ผ๊ตด', ๊ฐˆ์ƒ‰ ๊ธด ์ƒ๋จธ๋ฆฌ, C์ปต ์‚ฌ์ด์ฆˆ์˜ ํฐ ๊ฐ€์Šด, ํฐ ๊ณจ๋ฐ˜, ์˜คํ”ผ์Šค ์œ ๋‹ˆํผ, ์„น์Šค ํฌ์ฆˆ, ๋ฐฐ๊ฒฝ ํ˜ธํ…”, ํ–‰๋ณตํ•œ ํ‘œ์ •, ์ •๋ฉด ์‘์‹œ, ์ดˆ๊ณ ํ•ด์ƒ๋„ ์‚ฌ์ง„"
85
  ]
86
 
87
 
@@ -97,7 +108,7 @@ with gr.Blocks(css=CSS, js=JS, theme="soft") as demo:
97
  img2 = gr.Image(label='Generated Image 2')
98
  with gr.Accordion("Advanced Options", open=False):
99
  with gr.Row():
100
- negative = gr.Textbox(label="Negative prompt", value="low quality, (deformed, distorted, disfigured:1.3), poorly drawn, bad anatomy, wrong anatomy, extra limb, missing limb, floating limbs, (mutated hands and fingers:1.4), disconnected limbs, mutation, mutated, ugly, disgusting, blurry, amputation, (NSFW:1.25)")
101
  with gr.Row():
102
  width = gr.Slider(
103
  label="Width",
 
6
  from PIL import Image
7
  import requests
8
  from translatepy import Translator
9
+ import random
10
 
11
  translator = Translator()
12
 
 
25
 
26
  JS = """function () {
27
  gradioURL = window.location.href
28
+ if (!gradioURL.endsWith('?__theme=dark')) {
29
  window.location.replace(gradioURL + '?__theme=dark');
30
  }
31
  }"""
 
55
  prompt = str(translator.translate(prompt, 'English'))
56
 
57
  print(f'prompt:{prompt}')
58
+
59
+ generator1 = torch.manual_seed(random.randint(0, 10000))
60
+ generator2 = torch.manual_seed(random.randint(0, 10000))
61
+
62
+ images1 = pipe(
63
  prompt,
64
  negative_prompt=negative,
65
  width=width,
66
  height=height,
67
  guidance_scale=scale,
68
  num_inference_steps=steps,
69
+ generator=generator1
70
  ).images
71
 
72
+ images2 = pipe(
73
+ prompt,
74
+ negative_prompt=negative,
75
+ width=width,
76
+ height=height,
77
+ guidance_scale=scale,
78
+ num_inference_steps=steps,
79
+ generator=generator2
80
+ ).images
81
 
82
+ return images1[0], images2[0] # ๋‘ ์ด๋ฏธ์ง€๋ฅผ ๋ฐ˜ํ™˜
83
 
84
 
85
  examples = [
86
  "์•„๋ฆ„๋‹ค์šด 20์„ธ ํ•œ๊ตญ ์—ฌ์ž ๋ชจ๋ธ, 'ํ•œ๊ตญ ์—ฌ์ž๊ฐ€์ˆ˜ ์•„์ด์œ  ๋‹ฎ์€ ์–ผ๊ตด', ๊ฒ€์€์ƒ‰ ์งง์€ ๋‹จ๋ฐœ๋จธ๋ฆฌ, C์ปต ์‚ฌ์ด์ฆˆ์˜ ํฐ ๊ฐ€์Šด, ํฐ ๊ณจ๋ฐ˜, ๊ฐ€์ˆ˜ ์œ ๋‹ˆํผ, ๋ฐฐ๊ฒฝ ํฐ์ƒ‰, ์Šค๋งˆ์ผ ํ‘œ์ •, ๋ชจ๋ธ ํฌ์ฆˆ, ์ •๋ฉด ์‘์‹œ, ์ „์‹  ๋…ธ์ถœ, ์ดˆ๊ณ ํ•ด์ƒ๋„ ์‚ฌ์ง„",
87
  "์•„๋ฆ„๋‹ค์šด 20์„ธ ์˜๊ตญ ์—ฌ์ž ๋ชจ๋ธ, '์— ๋งˆ์™“์Šจ ๋‹ฎ์€ ์–ผ๊ตด', ๊ธˆ๋ฐœ ์งง์€ ๋‹จ๋ฐœ๋จธ๋ฆฌ, ์ด๋ธŒ๋‹ ๋“œ๋ ˆ์Šค, ๋ฐฐ๊ฒฝ ์‹œ์ƒ์‹, ์Šค๋งˆ์ผ ํ‘œ์ •, ๋ชจ๋ธ ํฌ์ฆˆ, ์ •๋ฉด ์‘์‹œ, ์ „์‹  ๋…ธ์ถœ, ์ดˆ๊ณ ํ•ด์ƒ๋„ ์‚ฌ์ง„",
88
  "์•„๋ฆ„๋‹ค์šด 20์„ธ ํ•œ๊ตญ ์—ฌ์ž ๋ชจ๋ธ, 'ํ•œ๊ตญ ์—ฌ์ž ์•„์ด๋Œ ๋‹ฎ์€ ์–ผ๊ตด', ๊ฒ€์€์ƒ‰ ์งง์€ ๋‹จ๋ฐœ๋จธ๋ฆฌ, ๋น„ํ‚ค๋‹ˆ ์ˆ˜์˜๋ณต, ๋ฐฐ๊ฒฝ ์ˆ˜์˜์žฅ, ์Šค๋งˆ์ผ ํ‘œ์ •, ๋ชจ๋ธ ํฌ์ฆˆ, ์ •๋ฉด ์‘์‹œ, ์ „์‹  ๋…ธ์ถœ, ์ดˆ๊ณ ํ•ด์ƒ๋„ ์‚ฌ์ง„",
89
+ "์•„๋ฆ„๋‹ค์šด 23์„ธ ์ค‘๊ตญ๊ตญ ์—ฌ์ž ๋ชจ๋ธ, ๊ฐˆ์ƒ‰ ๊ธด ์ƒ๋จธ๋ฆฌ, C์ปต ์‚ฌ์ด์ฆˆ์˜ ํฐ ๊ฐ€์Šด, ๋ฐฐ๊ฒฝ ์ŠคํŠœ๋””์˜ค, ์ง„์ง€ํ•œ ํ‘œ์ •, ์˜คํ”ผ์Šค ์œ ๋‹ˆํผ, ๋ชจ๋ธ ํฌ์ฆˆ, ์ •๋ฉด ์‘์‹œ, ์ดˆ๊ณ ํ•ด์ƒ๋„ ์‚ฌ์ง„",
90
+ "์•„๋ฆ„๋‹ค์šด 18์„ธ ์ผ๋ณธ ์—ฌ์ž ๋ชจ๋ธ, ๊ฒ€์€์ƒ‰ ์งง์€ ๋‹จ๋ฐœ๋จธ๋ฆฌ, ์Šค๋งˆ์ผ ํ‘œ์ •, ๊ต๋ณต ์œ ๋‹ˆํผ, ๋ฐฐ๊ฒฝ ํ•™๊ต ๊ต์‹ค, ๋ชจ๋ธ ํฌ์ฆˆ, ์ •๋ฉด ์‘์‹œ, ์ดˆ๊ณ ํ•ด์ƒ๋„ ์‚ฌ์ง„",
91
+ "์•„๋ฆ„๋‹ค์šด 20์„ธ ๋ธŒ๋ผ์งˆ ์—ฌ์ž ๋ชจ๋ธ, ๊ฒ€์€์ƒ‰ ์งง์€ ๋‹จ๋ฐœ๋จธ๋ฆฌ, C์ปต ์‚ฌ์ด์ฆˆ์˜ ํฐ ๊ฐ€์Šด, ํฐ ๊ณจ๋ฐ˜, ๊ฐ„ํ˜ธ์‚ฌ ์œ ๋‹ˆํผ, ๋ฐฐ๊ฒฝ ํฐ์ƒ‰, ์Šค๋งˆ์ผ ํ‘œ์ •, ๋ชจ๋ธ ํฌ์ฆˆ, ์ •๋ฉด ์‘์‹œ, ์ „์‹  ๋…ธ์ถœ, ์ดˆ๊ณ ํ•ด์ƒ๋„ ์‚ฌ์ง„",
92
+ "์•„๋ฆ„๋‹ค์šด 20์„ธ ์Šค์›จ๋ด ์—ฌ์ž ๋ชจ๋ธ, ๊ธˆ๋ฐœ ๊ธด ์ƒ๋จธ๋ฆฌ, C์ปต ์‚ฌ์ด์ฆˆ์˜ ํฐ ๊ฐ€์Šด, ํฐ ๊ณจ๋ฐ˜, ๋น„ํ‚ค๋‹ˆ ์ˆ˜์˜๋ณต, ๋ฐฐ๊ฒฝ ํ•ด๋ณ€๊ฐ€, ์Šค๋งˆ์ผ ํ‘œ์ •, ๋ชจ๋ธ ํฌ์ฆˆ, ์ •๋ฉด ์‘์‹œ, ์ดˆ๊ณ ํ•ด์ƒ๋„ ์‚ฌ์ง„",
93
+ "์•„๋ฆ„๋‹ค์šด 18์„ธ ๋Ÿฌ์‹œ์•„ ์—ฌ์ž ๋ชจ๋ธ, ๊ธˆ๋ฐœ ์งง์€ ๋‹จ๋ฐœ๋จธ๋ฆฌ, C์ปต ์‚ฌ์ด์ฆˆ์˜ ํฐ ๊ฐ€์Šด, ํฐ ๊ณจ๋ฐ˜, ๋น„ํ‚ค๋‹ˆ ์ˆ˜์˜๋ณต, ๋ฐฐ๊ฒฝ ์ˆ˜์˜์žฅ, ์—„์ˆ™ํ•œ ํ‘œ์ •, ๋ชจ๋ธ ํฌ์ฆˆ, ์ •๋ฉด ์‘์‹œ, ์ดˆ๊ณ ํ•ด์ƒ๋„ ์‚ฌ์ง„",
94
+ "์•„๋ฆ„๋‹ค์šด 20์„ธ ํ”„๋ž‘์Šค ์—ฌ์ž ๋ชจ๋ธ, ๊ฐˆ์ƒ‰ ์งง์€ ๋‹จ๋ฐœ๋จธ๋ฆฌ, C์ปต ์‚ฌ์ด์ฆˆ์˜ ํฐ ๊ฐ€์Šด, ํฐ ๊ณจ๋ฐ˜, ๋น„์ฆˆ๋‹ˆ์Šค ์ •์žฅ, ๋ฐฐ๊ฒฝ ์‚ฌ๋ฌด์‹ค, ํฌ๊ฒŒ ์›ƒ๋Š” ํ‘œ์ •, ๋ชจ๋ธ ํฌ์ฆˆ, ์ •๋ฉด ์‘์‹œ, ์ดˆ๊ณ ํ•ด์ƒ๋„ ์‚ฌ์ง„",
95
+ "์•„๋ฆ„๋‹ค์šด 16์„ธ ์šฐํฌ๋ผ์ด๋‚˜ ์—ฌ์ž ๋ชจ๋ธ, ๊ฐˆ์ƒ‰ ๊ธด ์ƒ๋จธ๋ฆฌ, C์ปต ์‚ฌ์ด์ฆˆ์˜ ํฐ ๊ฐ€์Šด, ํฐ ๊ณจ๋ฐ˜, ์˜คํ”ผ์Šค ์œ ๋‹ˆํผ, ์„น์Šค ํฌ์ฆˆ, ๋ฐฐ๊ฒฝ ํ˜ธํ…”, ํ–‰๋ณตํ•œ ํ‘œ์ •, ์ •๋ฉด ์‘์‹œ, ์ดˆ๊ณ ํ•ด์ƒ๋„ ์‚ฌ์ง„"
96
  ]
97
 
98
 
 
108
  img2 = gr.Image(label='Generated Image 2')
109
  with gr.Accordion("Advanced Options", open=False):
110
  with gr.Row():
111
+ negative = gr.Textbox(label="Negative prompt", value="low quality, low quality, (deformed, distorted, disfigured:1.3), poorly drawn, bad anatomy, wrong anatomy, extra limb, missing limb, floating limbs, (mutated hands and fingers:1.4), disconnected limbs, mutation, mutated, ugly, disgusting, blurry, amputation, (NSFW:1.25)")
112
  with gr.Row():
113
  width = gr.Slider(
114
  label="Width",