remove excess logging
Browse files
app.py
CHANGED
@@ -53,14 +53,12 @@ def query(prompt, negative_prompt="", steps=30, cfg_scale=7, seed=-1, width=1024
|
|
53 |
# Translation
|
54 |
try:
|
55 |
translated_prompt = GoogleTranslator(source='auto', target='en').translate(prompt)
|
56 |
-
print(f'Generation {key} translation: {translated_prompt}')
|
57 |
except Exception as e:
|
58 |
-
print(f"Translation failed: {e}. Using original prompt.")
|
59 |
translated_prompt = prompt # Fallback to original if translation fails
|
60 |
|
61 |
# Add suffix to prompt
|
62 |
final_prompt = f"{translated_prompt} | ultra detail, ultra elaboration, ultra quality, perfect."
|
63 |
-
print(f'Generation {key}
|
64 |
|
65 |
# Prepare the payload for the API call
|
66 |
payload = {
|
@@ -95,13 +93,10 @@ def query(prompt, negative_prompt="", steps=30, cfg_scale=7, seed=-1, width=1024
|
|
95 |
|
96 |
try:
|
97 |
image = Image.open(io.BytesIO(image_bytes))
|
98 |
-
print(f"Image received and opened successfully. Format: {image.format}, Size: {image.size}")
|
99 |
except UnidentifiedImageError as img_err:
|
100 |
print(f"Error: Could not identify or open image from API response bytes: {img_err}")
|
101 |
return None, "<p style='color: red; text-align: center;'>Failed to process image data from API.</p>"
|
102 |
|
103 |
-
print(f'Generation {key} API call successful!')
|
104 |
-
|
105 |
# --- Save image and create download link ---
|
106 |
filename = f"{int(time.time())}_{uuid.uuid4().hex[:8]}.png"
|
107 |
save_path = os.path.join(IMAGE_DIR, filename)
|
@@ -113,8 +108,6 @@ def query(prompt, negative_prompt="", steps=30, cfg_scale=7, seed=-1, width=1024
|
|
113 |
|
114 |
if os.path.exists(save_path):
|
115 |
file_size = os.path.getsize(save_path)
|
116 |
-
print(f"SUCCESS: Image confirmed saved to: {save_path} (Absolute: {absolute_save_path})")
|
117 |
-
print(f"Saved file size: {file_size} bytes")
|
118 |
if file_size < 100:
|
119 |
print(f"WARNING: Saved file {save_path} is very small ({file_size} bytes). May indicate an issue.")
|
120 |
else:
|
@@ -128,14 +121,12 @@ def query(prompt, negative_prompt="", steps=30, cfg_scale=7, seed=-1, width=1024
|
|
128 |
except IndexError:
|
129 |
print("WARNING: Could not reliably determine space name from API_URL. Using a default.")
|
130 |
space_name = "unknown-flux-space" # Provide a fallback
|
131 |
-
print(f"Current space name: {space_name}")
|
132 |
|
133 |
relative_file_url = f"/gradio_api/file={save_path}"
|
134 |
-
print(f"Generated relative file URL for Gradio API: {relative_file_url}")
|
135 |
|
136 |
encoded_file_url = quote(relative_file_url)
|
137 |
arintelli_url = f"{ARINTELLI_REDIRECT_BASE}?download_url={encoded_file_url}&space_name={space_name}"
|
138 |
-
print(f"
|
139 |
|
140 |
# Use Gradio's primary button style for the link
|
141 |
download_html = (
|
@@ -207,7 +198,7 @@ css = """
|
|
207 |
textarea:focus {
|
208 |
background: #0d1117 !important;
|
209 |
}
|
210 |
-
#download-link-container p {
|
211 |
margin-top: 10px;
|
212 |
font-size: 0.9em;
|
213 |
}
|
|
|
53 |
# Translation
|
54 |
try:
|
55 |
translated_prompt = GoogleTranslator(source='auto', target='en').translate(prompt)
|
|
|
56 |
except Exception as e:
|
|
|
57 |
translated_prompt = prompt # Fallback to original if translation fails
|
58 |
|
59 |
# Add suffix to prompt
|
60 |
final_prompt = f"{translated_prompt} | ultra detail, ultra elaboration, ultra quality, perfect."
|
61 |
+
print(f'Generation {key} prompt: {final_prompt}')
|
62 |
|
63 |
# Prepare the payload for the API call
|
64 |
payload = {
|
|
|
93 |
|
94 |
try:
|
95 |
image = Image.open(io.BytesIO(image_bytes))
|
|
|
96 |
except UnidentifiedImageError as img_err:
|
97 |
print(f"Error: Could not identify or open image from API response bytes: {img_err}")
|
98 |
return None, "<p style='color: red; text-align: center;'>Failed to process image data from API.</p>"
|
99 |
|
|
|
|
|
100 |
# --- Save image and create download link ---
|
101 |
filename = f"{int(time.time())}_{uuid.uuid4().hex[:8]}.png"
|
102 |
save_path = os.path.join(IMAGE_DIR, filename)
|
|
|
108 |
|
109 |
if os.path.exists(save_path):
|
110 |
file_size = os.path.getsize(save_path)
|
|
|
|
|
111 |
if file_size < 100:
|
112 |
print(f"WARNING: Saved file {save_path} is very small ({file_size} bytes). May indicate an issue.")
|
113 |
else:
|
|
|
121 |
except IndexError:
|
122 |
print("WARNING: Could not reliably determine space name from API_URL. Using a default.")
|
123 |
space_name = "unknown-flux-space" # Provide a fallback
|
|
|
124 |
|
125 |
relative_file_url = f"/gradio_api/file={save_path}"
|
|
|
126 |
|
127 |
encoded_file_url = quote(relative_file_url)
|
128 |
arintelli_url = f"{ARINTELLI_REDIRECT_BASE}?download_url={encoded_file_url}&space_name={space_name}"
|
129 |
+
print(f"Generation link: {arintelli_url}")
|
130 |
|
131 |
# Use Gradio's primary button style for the link
|
132 |
download_html = (
|
|
|
198 |
textarea:focus {
|
199 |
background: #0d1117 !important;
|
200 |
}
|
201 |
+
#download-link-container p {
|
202 |
margin-top: 10px;
|
203 |
font-size: 0.9em;
|
204 |
}
|