Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -13,13 +13,18 @@ import requests
|
|
| 13 |
from loguru import logger
|
| 14 |
from decouple import config
|
| 15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
URL = config('URL')
|
| 17 |
OUTPUT_DIR = config('OUTPUT_DIR')
|
|
|
|
| 18 |
COMF_PATH = config('COMF_PATH')
|
| 19 |
|
| 20 |
import torch
|
| 21 |
|
| 22 |
-
import spaces
|
| 23 |
|
| 24 |
print(f"Is CUDA available: {torch.cuda.is_available()}")
|
| 25 |
print(f"CUDA device: {torch.cuda.get_device_name(torch.cuda.current_device())}")
|
|
@@ -50,10 +55,14 @@ def check_server_ready():
|
|
| 50 |
return False
|
| 51 |
|
| 52 |
|
| 53 |
-
@spaces.GPU
|
| 54 |
-
def generate_image(prompt):
|
| 55 |
previous_image = get_latest_image(OUTPUT_DIR)
|
| 56 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
# Запускаем скрипт как подпроцесс
|
| 58 |
process = subprocess.Popen([sys.executable, COMF_PATH, "--listen", "127.0.0.1"])
|
| 59 |
logger.debug(f'Subprocess started with PID: {process.pid}')
|
|
@@ -97,7 +106,7 @@ def generate_image(prompt):
|
|
| 97 |
|
| 98 |
|
| 99 |
if __name__ == "__main__":
|
| 100 |
-
demo = gr.Interface(fn=generate_image, inputs=["text"], outputs=["image"])
|
| 101 |
demo.launch(debug=True)
|
| 102 |
logger.debug('demo.launch()')
|
| 103 |
|
|
|
|
| 13 |
from loguru import logger
|
| 14 |
from decouple import config
|
| 15 |
|
| 16 |
+
from pathlib import Path
|
| 17 |
+
from PIL import Image
|
| 18 |
+
import io
|
| 19 |
+
|
| 20 |
URL = config('URL')
|
| 21 |
OUTPUT_DIR = config('OUTPUT_DIR')
|
| 22 |
+
INPUT_DIR = config('INPUT_DIR')
|
| 23 |
COMF_PATH = config('COMF_PATH')
|
| 24 |
|
| 25 |
import torch
|
| 26 |
|
| 27 |
+
#import spaces
|
| 28 |
|
| 29 |
print(f"Is CUDA available: {torch.cuda.is_available()}")
|
| 30 |
print(f"CUDA device: {torch.cuda.get_device_name(torch.cuda.current_device())}")
|
|
|
|
| 55 |
return False
|
| 56 |
|
| 57 |
|
| 58 |
+
#@spaces.GPU
|
| 59 |
+
def generate_image(prompt, image):
|
| 60 |
previous_image = get_latest_image(OUTPUT_DIR)
|
| 61 |
|
| 62 |
+
image = Image.fromarray(image)
|
| 63 |
+
image.save(OUTPUT_DIR+'/input.png', format='PNG')
|
| 64 |
+
|
| 65 |
+
|
| 66 |
# Запускаем скрипт как подпроцесс
|
| 67 |
process = subprocess.Popen([sys.executable, COMF_PATH, "--listen", "127.0.0.1"])
|
| 68 |
logger.debug(f'Subprocess started with PID: {process.pid}')
|
|
|
|
| 106 |
|
| 107 |
|
| 108 |
if __name__ == "__main__":
|
| 109 |
+
demo = gr.Interface(fn=generate_image, inputs=["text", "image"], outputs=["image"])
|
| 110 |
demo.launch(debug=True)
|
| 111 |
logger.debug('demo.launch()')
|
| 112 |
|