openfree commited on
Commit
99c00c1
1 Parent(s): 3da000f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -2
app.py CHANGED
@@ -14,6 +14,10 @@ import random
14
  import time
15
  import requests
16
  import pandas as pd
 
 
 
 
17
 
18
  #Load prompts for randomization
19
  df = pd.read_csv('prompts.csv', header=None)
@@ -309,12 +313,18 @@ def generate_image_to_image(prompt_mash, image_input_path, image_strength, steps
309
  ).images[0]
310
  return final_image
311
 
 
312
  def run_lora(prompt, image_input, image_strength, cfg_scale, steps, selected_indices, lora_scale_1, lora_scale_2, randomize_seed, seed, width, height, loras_state, progress=gr.Progress(track_tqdm=True)):
 
 
 
 
 
 
 
313
  if not selected_indices:
314
  raise gr.Error("You must select at least one LoRA before proceeding.")
315
 
316
- selected_loras = [loras_state[idx] for idx in selected_indices]
317
-
318
  # Build the prompt with trigger words
319
  prepends = []
320
  appends = []
 
14
  import time
15
  import requests
16
  import pandas as pd
17
+ from transformers import pipeline
18
+
19
+ # 번역 모델 로드
20
+ translator = pipeline("translation", model="Helsinki-NLP/opus-mt-ko-en")
21
 
22
  #Load prompts for randomization
23
  df = pd.read_csv('prompts.csv', header=None)
 
313
  ).images[0]
314
  return final_image
315
 
316
+
317
  def run_lora(prompt, image_input, image_strength, cfg_scale, steps, selected_indices, lora_scale_1, lora_scale_2, randomize_seed, seed, width, height, loras_state, progress=gr.Progress(track_tqdm=True)):
318
+ # 한글 감지 및 번역
319
+ if any('\u3131' <= char <= '\u318E' or '\uAC00' <= char <= '\uD7A3' for char in prompt):
320
+ translated = translator(prompt, max_length=512)[0]['translation_text']
321
+ print(f"Original prompt: {prompt}")
322
+ print(f"Translated prompt: {translated}")
323
+ prompt = translated
324
+
325
  if not selected_indices:
326
  raise gr.Error("You must select at least one LoRA before proceeding.")
327
 
 
 
328
  # Build the prompt with trigger words
329
  prepends = []
330
  appends = []