Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -112,11 +112,11 @@ def polish_prompt_hf(prompt, img_list):
|
|
| 112 |
# Initialize the client
|
| 113 |
prompt = f"{SYSTEM_PROMPT}\n\nUser Input: {prompt}\n\nRewritten Prompt:"
|
| 114 |
client = InferenceClient(
|
| 115 |
-
provider="
|
| 116 |
api_key=api_key,
|
| 117 |
)
|
| 118 |
|
| 119 |
-
|
| 120 |
if img is not None:
|
| 121 |
# If img is a PIL Image
|
| 122 |
if hasattr(img, 'save'): # Check if it's a PIL Image
|
|
@@ -177,8 +177,11 @@ def polish_prompt_hf(prompt, img_list):
|
|
| 177 |
|
| 178 |
polished_prompt = polished_prompt.strip().replace("\n", " ")
|
| 179 |
return polished_prompt
|
| 180 |
-
|
| 181 |
-
|
|
|
|
|
|
|
|
|
|
| 182 |
|
| 183 |
def encode_image(pil_image):
|
| 184 |
import io
|
|
|
|
| 112 |
# Initialize the client
|
| 113 |
prompt = f"{SYSTEM_PROMPT}\n\nUser Input: {prompt}\n\nRewritten Prompt:"
|
| 114 |
client = InferenceClient(
|
| 115 |
+
provider="nebius",
|
| 116 |
api_key=api_key,
|
| 117 |
)
|
| 118 |
|
| 119 |
+
image_url = None
|
| 120 |
if img is not None:
|
| 121 |
# If img is a PIL Image
|
| 122 |
if hasattr(img, 'save'): # Check if it's a PIL Image
|
|
|
|
| 177 |
|
| 178 |
polished_prompt = polished_prompt.strip().replace("\n", " ")
|
| 179 |
return polished_prompt
|
| 180 |
+
|
| 181 |
+
except Exception as e:
|
| 182 |
+
print(f"Error during API call to Hugging Face: {e}")
|
| 183 |
+
# Fallback to original prompt if enhancement fails
|
| 184 |
+
return original_prompt
|
| 185 |
|
| 186 |
def encode_image(pil_image):
|
| 187 |
import io
|