Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,7 +8,10 @@ from deep_translator import GoogleTranslator
|
|
| 8 |
|
| 9 |
app = Flask(__name__)
|
| 10 |
|
| 11 |
-
API_URL = "https://api-inference.huggingface.co/models/black-forest-labs/FLUX.1-
|
|
|
|
|
|
|
|
|
|
| 12 |
timeout = 50000 # タイムアウトを300秒に設定
|
| 13 |
|
| 14 |
# Function to query the API and return the generated image
|
|
@@ -42,7 +45,7 @@ def query(prompt, negative_prompt="", steps=35, cfg_scale=7, sampler="DPM++ 2M K
|
|
| 42 |
|
| 43 |
for attempt in range(3): # 最大3回の再試行
|
| 44 |
try:
|
| 45 |
-
response = requests.post(API_URL, json=payload, timeout=timeout)
|
| 46 |
if response.status_code != 200:
|
| 47 |
return None, f"Error: Failed to get image. Status code: {response.status_code}, Details: {response.text}"
|
| 48 |
|
|
|
|
| 8 |
|
| 9 |
app = Flask(__name__)
|
| 10 |
|
| 11 |
+
API_URL = "https://api-inference.huggingface.co/models/black-forest-labs/FLUX.1-dev"
|
| 12 |
+
|
| 13 |
+
API_TOKEN = os.getenv("HF_READ_TOKEN")
|
| 14 |
+
headers = {"Authorization": f"Bearer {API_TOKEN}"}
|
| 15 |
timeout = 50000 # タイムアウトを300秒に設定
|
| 16 |
|
| 17 |
# Function to query the API and return the generated image
|
|
|
|
| 45 |
|
| 46 |
for attempt in range(3): # 最大3回の再試行
|
| 47 |
try:
|
| 48 |
+
response = requests.post(API_URL, json=payload, headers=headers, timeout=timeout)
|
| 49 |
if response.status_code != 200:
|
| 50 |
return None, f"Error: Failed to get image. Status code: {response.status_code}, Details: {response.text}"
|
| 51 |
|