ginipick commited on
Commit
90d19a9
ยท
verified ยท
1 Parent(s): 5ca375c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -23
app.py CHANGED
@@ -7,10 +7,6 @@ import time
7
  import os
8
  from diffusers import DiffusionPipeline
9
  from custom_pipeline import FLUXPipelineWithIntermediateOutputs
10
- from transformers import pipeline
11
-
12
- # ๋ฒˆ์—ญ ๋ชจ๋ธ ์„ค์ • (CPU ์‚ฌ์šฉ)
13
- translator = pipeline("translation", model="Helsinki-NLP/opus-mt-ko-en", device="cpu")
14
 
15
  # ์ƒ์ˆ˜ ์ •์˜
16
  MAX_SEED = np.iinfo(np.int32).max
@@ -20,6 +16,11 @@ DEFAULT_HEIGHT = 1024
20
  DEFAULT_INFERENCE_STEPS = 1
21
  GPU_DURATION = 15 # GPU ํ• ๋‹น ์‹œ๊ฐ„ ์ถ•์†Œ
22
 
 
 
 
 
 
23
  # ๋ชจ๋ธ ์„ค์ •
24
  def setup_model():
25
  dtype = torch.float16
@@ -45,16 +46,6 @@ labels = {
45
  "Inspiration Gallery": "์˜๊ฐ ๊ฐค๋Ÿฌ๋ฆฌ"
46
  }
47
 
48
- def translate_if_korean(text):
49
- """ํ•œ๊ธ€ ํ…์ŠคํŠธ๋ฅผ ์˜์–ด๋กœ ์•ˆ์ „ํ•˜๊ฒŒ ๋ฒˆ์—ญ"""
50
- try:
51
- if any('\u3131' <= char <= '\u3163' or '\uac00' <= char <= '\ud7a3' for char in text):
52
- return translator(text)[0]['translation_text']
53
- return text
54
- except Exception as e:
55
- print(f"๋ฒˆ์—ญ ์˜ค๋ฅ˜: {e}")
56
- return text
57
-
58
  # ์ด๋ฏธ์ง€ ์ƒ์„ฑ ํ•จ์ˆ˜
59
  @spaces.GPU(duration=GPU_DURATION)
60
  def generate_image(prompt, seed=None, width=DEFAULT_WIDTH, height=DEFAULT_HEIGHT,
@@ -64,8 +55,10 @@ def generate_image(prompt, seed=None, width=DEFAULT_WIDTH, height=DEFAULT_HEIGHT
64
  if not isinstance(seed, (int, type(None))):
65
  seed = None
66
  randomize_seed = True
67
-
68
- prompt = translate_if_korean(prompt)
 
 
69
 
70
  if seed is None or randomize_seed:
71
  seed = random.randint(0, MAX_SEED)
@@ -179,11 +172,6 @@ def create_snow_effect():
179
 
180
  return gr.HTML(snow_html)
181
 
182
- # Gradio ์•ฑ์—์„œ ์‚ฌ์šฉํ•  ๋•Œ:
183
- # with app: ์•„๋ž˜์—
184
-
185
-
186
-
187
  # Gradio UI ๊ตฌ์„ฑ
188
  with gr.Blocks(theme="Yntec/HaleyCH_Theme_Orange", css=css) as demo:
189
 
@@ -283,5 +271,4 @@ with gr.Blocks(theme="Yntec/HaleyCH_Theme_Orange", css=css) as demo:
283
  )
284
 
285
  if __name__ == "__main__":
286
- demo.launch()
287
-
 
7
  import os
8
  from diffusers import DiffusionPipeline
9
  from custom_pipeline import FLUXPipelineWithIntermediateOutputs
 
 
 
 
10
 
11
  # ์ƒ์ˆ˜ ์ •์˜
12
  MAX_SEED = np.iinfo(np.int32).max
 
16
  DEFAULT_INFERENCE_STEPS = 1
17
  GPU_DURATION = 15 # GPU ํ• ๋‹น ์‹œ๊ฐ„ ์ถ•์†Œ
18
 
19
+ # ๊ฐ„๋‹จํ•œ ํ•œ๊ธ€ ๊ฐ์ง€ ํ•จ์ˆ˜
20
+ def is_korean(text):
21
+ """ํ•œ๊ธ€ ํฌํ•จ ์—ฌ๋ถ€ ํ™•์ธ"""
22
+ return any('\u3131' <= char <= '\u3163' or '\uac00' <= char <= '\ud7a3' for char in text)
23
+
24
  # ๋ชจ๋ธ ์„ค์ •
25
  def setup_model():
26
  dtype = torch.float16
 
46
  "Inspiration Gallery": "์˜๊ฐ ๊ฐค๋Ÿฌ๋ฆฌ"
47
  }
48
 
 
 
 
 
 
 
 
 
 
 
49
  # ์ด๋ฏธ์ง€ ์ƒ์„ฑ ํ•จ์ˆ˜
50
  @spaces.GPU(duration=GPU_DURATION)
51
  def generate_image(prompt, seed=None, width=DEFAULT_WIDTH, height=DEFAULT_HEIGHT,
 
55
  if not isinstance(seed, (int, type(None))):
56
  seed = None
57
  randomize_seed = True
58
+
59
+ # ํ•œ๊ธ€ ํ”„๋กฌํ”„ํŠธ์— ๋Œ€ํ•œ ๊ฒฝ๊ณ  ๋ฉ”์‹œ์ง€ ์ถ”๊ฐ€
60
+ if is_korean(prompt):
61
+ print("๊ฒฝ๊ณ : ํ•œ๊ธ€ ํ”„๋กฌํ”„ํŠธ๋Š” ์ง์ ‘ ์ฒ˜๋ฆฌ๋ฉ๋‹ˆ๋‹ค. ๋ฒˆ์—ญ๊ธฐ๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.")
62
 
63
  if seed is None or randomize_seed:
64
  seed = random.randint(0, MAX_SEED)
 
172
 
173
  return gr.HTML(snow_html)
174
 
 
 
 
 
 
175
  # Gradio UI ๊ตฌ์„ฑ
176
  with gr.Blocks(theme="Yntec/HaleyCH_Theme_Orange", css=css) as demo:
177
 
 
271
  )
272
 
273
  if __name__ == "__main__":
274
+ demo.launch()