Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -17,7 +17,7 @@ from pathlib import Path
|
|
17 |
from PIL import Image
|
18 |
import io
|
19 |
|
20 |
-
URL
|
21 |
OUTPUT_DIR = config('OUTPUT_DIR')
|
22 |
INPUT_DIR = config('INPUT_DIR')
|
23 |
COMF_PATH = config('COMF_PATH')
|
@@ -72,12 +72,12 @@ def delete_image_file(file_path):
|
|
72 |
def start_queue(prompt_workflow, port):
|
73 |
p = {"prompt": prompt_workflow}
|
74 |
data = json.dumps(p).encode('utf-8')
|
75 |
-
requests.post(URL
|
76 |
|
77 |
|
78 |
def check_server_ready(port):
|
79 |
try:
|
80 |
-
response = requests.get(f"{URL}{port}/history/123", timeout=5)
|
81 |
return response.status_code == 200
|
82 |
except requests.RequestException:
|
83 |
return False
|
@@ -94,7 +94,7 @@ def generate_image(prompt, image):
|
|
94 |
image.save(INPUT_DIR + '/input.png', format='PNG')
|
95 |
|
96 |
process = None
|
97 |
-
new_port = str(random.randint(8123,
|
98 |
|
99 |
try:
|
100 |
# Запускаем скрипт как подпроцесс
|
@@ -102,7 +102,7 @@ def generate_image(prompt, image):
|
|
102 |
logger.debug(f'Subprocess started with PID: {process.pid}')
|
103 |
|
104 |
# Ожидание запуска сервера
|
105 |
-
for _ in range(
|
106 |
if check_server_ready(new_port):
|
107 |
break
|
108 |
time.sleep(1)
|
|
|
17 |
from PIL import Image
|
18 |
import io
|
19 |
|
20 |
+
URL="http://127.0.0.1"
|
21 |
OUTPUT_DIR = config('OUTPUT_DIR')
|
22 |
INPUT_DIR = config('INPUT_DIR')
|
23 |
COMF_PATH = config('COMF_PATH')
|
|
|
72 |
def start_queue(prompt_workflow, port):
|
73 |
p = {"prompt": prompt_workflow}
|
74 |
data = json.dumps(p).encode('utf-8')
|
75 |
+
requests.post(f"{URL}:{port}/prompt", data=data)
|
76 |
|
77 |
|
78 |
def check_server_ready(port):
|
79 |
try:
|
80 |
+
response = requests.get(f"{URL}:{port}/history/123", timeout=5)
|
81 |
return response.status_code == 200
|
82 |
except requests.RequestException:
|
83 |
return False
|
|
|
94 |
image.save(INPUT_DIR + '/input.png', format='PNG')
|
95 |
|
96 |
process = None
|
97 |
+
new_port = str(random.randint(8123, 8200))
|
98 |
|
99 |
try:
|
100 |
# Запускаем скрипт как подпроцесс
|
|
|
102 |
logger.debug(f'Subprocess started with PID: {process.pid}')
|
103 |
|
104 |
# Ожидание запуска сервера
|
105 |
+
for _ in range(30): # Максимум 20 секунд ожидания
|
106 |
if check_server_ready(new_port):
|
107 |
break
|
108 |
time.sleep(1)
|