Spaces:
Running
Running
salomonsky
commited on
Commit
•
7c78be7
1
Parent(s):
d726a64
Update app.py
Browse files
app.py
CHANGED
@@ -57,9 +57,16 @@ async def gen(prompt, basemodel, w, h, scales, steps, seed, upscale_factor, proc
|
|
57 |
return [str(image_path), str(prompt_file_path)]
|
58 |
|
59 |
async def improve_prompt(prompt, language):
|
60 |
-
|
61 |
-
|
62 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
|
64 |
def save_image(image, seed):
|
65 |
if image.mode == 'RGBA': image = image.convert('RGB')
|
|
|
57 |
return [str(image_path), str(prompt_file_path)]
|
58 |
|
59 |
async def improve_prompt(prompt, language):
|
60 |
+
try:
|
61 |
+
instruction_en = "With this idea, describe in English a detailed txt2img prompt in 500 characters at most, add illumination, atmosphere, cinematic elements, and characters if need it..."
|
62 |
+
instruction_es = "Con esta idea, describe en español un prompt detallado de txt2img en un máximo de 500 caracteres, con iluminación, atmósfera, elementos cinematográficos y en su caso personajes..."
|
63 |
+
instruction = instruction_en if language == "en" else instruction_es
|
64 |
+
formatted_prompt = f"{prompt}: {instruction}"
|
65 |
+
response = llm_client.text_generation(formatted_prompt, max_new_tokens=500)
|
66 |
+
improved_text = response['generated_text'].strip() if 'generated_text' in response else response.strip()
|
67 |
+
return improved_text[:500] if len(improved_text) > 500 else improved_text
|
68 |
+
except Exception as e:
|
69 |
+
return f"Error mejorando el prompt: {e}"
|
70 |
|
71 |
def save_image(image, seed):
|
72 |
if image.mode == 'RGBA': image = image.convert('RGB')
|