Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -40,9 +40,13 @@ def authenticate_user(username, password):
|
|
40 |
def list_saved_images():
|
41 |
return sorted(DATA_PATH.glob("*.jpg"), key=lambda x: x.stat().st_mtime, reverse=True)
|
42 |
|
43 |
-
def enhance_prompt(text, client=client):
|
|
|
|
|
|
|
44 |
if not client:
|
45 |
return text[:200]
|
|
|
46 |
try:
|
47 |
enhanced = client.text_generation(
|
48 |
"Generate a photorealistic, detailed txt2img prompt: " + text,
|
@@ -53,10 +57,6 @@ def enhance_prompt(text, client=client):
|
|
53 |
st.warning(f"Prompt enhancement error: {e}")
|
54 |
return text[:200]
|
55 |
|
56 |
-
def save_prompt(image_name, enhanced_prompt):
|
57 |
-
with open(DATA_PATH / "prompts.txt", "a") as f:
|
58 |
-
f.write(f"{image_name}: {enhanced_prompt}\n")
|
59 |
-
|
60 |
def generate_variations(prompt, num_variants=8, use_enhanced=True):
|
61 |
instructions = [
|
62 |
"Photorealistic description for txt2img prompt: ",
|
|
|
40 |
def list_saved_images():
|
41 |
return sorted(DATA_PATH.glob("*.jpg"), key=lambda x: x.stat().st_mtime, reverse=True)
|
42 |
|
43 |
+
def enhance_prompt(text, client=client, use_enhancement=True):
|
44 |
+
if not use_enhancement:
|
45 |
+
return text[:200]
|
46 |
+
|
47 |
if not client:
|
48 |
return text[:200]
|
49 |
+
|
50 |
try:
|
51 |
enhanced = client.text_generation(
|
52 |
"Generate a photorealistic, detailed txt2img prompt: " + text,
|
|
|
57 |
st.warning(f"Prompt enhancement error: {e}")
|
58 |
return text[:200]
|
59 |
|
|
|
|
|
|
|
|
|
60 |
def generate_variations(prompt, num_variants=8, use_enhanced=True):
|
61 |
instructions = [
|
62 |
"Photorealistic description for txt2img prompt: ",
|