Spaces:
Paused
Paused
Bobby commited on
Commit ·
003422e
1
Parent(s): 52c8e07
upload
Browse files
app.py
CHANGED
|
@@ -11,7 +11,8 @@ import time
|
|
| 11 |
import gradio as gr
|
| 12 |
import numpy as np
|
| 13 |
import spaces
|
| 14 |
-
|
|
|
|
| 15 |
import gc
|
| 16 |
import torch
|
| 17 |
from PIL import Image
|
|
@@ -30,6 +31,7 @@ API_KEY = os.environ.get("API_KEY", None)
|
|
| 30 |
print("CUDA version:", torch.version.cuda)
|
| 31 |
print("loading everything")
|
| 32 |
compiled = False
|
|
|
|
| 33 |
|
| 34 |
class Preprocessor:
|
| 35 |
MODEL_ID = "lllyasviel/Annotators"
|
|
@@ -434,6 +436,26 @@ def process_image(
|
|
| 434 |
print(f"\n-------------------------Inference done in: {time.time() - start:.2f} seconds-------------------------")
|
| 435 |
# torch.cuda.synchronize()
|
| 436 |
torch.cuda.empty_cache()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 437 |
return results
|
| 438 |
|
| 439 |
if prod:
|
|
|
|
| 11 |
import gradio as gr
|
| 12 |
import numpy as np
|
| 13 |
import spaces
|
| 14 |
+
import imageio
|
| 15 |
+
from huggingface_hub import HfApi
|
| 16 |
import gc
|
| 17 |
import torch
|
| 18 |
from PIL import Image
|
|
|
|
| 31 |
print("CUDA version:", torch.version.cuda)
|
| 32 |
print("loading everything")
|
| 33 |
compiled = False
|
| 34 |
+
api = HfApi()
|
| 35 |
|
| 36 |
class Preprocessor:
|
| 37 |
MODEL_ID = "lllyasviel/Annotators"
|
|
|
|
| 436 |
print(f"\n-------------------------Inference done in: {time.time() - start:.2f} seconds-------------------------")
|
| 437 |
# torch.cuda.synchronize()
|
| 438 |
torch.cuda.empty_cache()
|
| 439 |
+
timestamp = int(time.time())
|
| 440 |
+
img_path = f"{timestamp}.jpg"
|
| 441 |
+
results_path = f"{timestamp}_out_{prompt}.jpg"
|
| 442 |
+
imageio.imsave(img_path, image)
|
| 443 |
+
api.upload_file(
|
| 444 |
+
path_or_fileobj=img_path,
|
| 445 |
+
path_in_repo=img_path,
|
| 446 |
+
repo_id="broyang/interior-ai-outputs",
|
| 447 |
+
repo_type="dataset",
|
| 448 |
+
token=API_KEY,
|
| 449 |
+
run_as_future=True,
|
| 450 |
+
)
|
| 451 |
+
api.upload_file(
|
| 452 |
+
path_or_fileobj=results_path,
|
| 453 |
+
path_in_repo=results_path,
|
| 454 |
+
repo_id="broyang/interior-ai-outputs",
|
| 455 |
+
repo_type="dataset",
|
| 456 |
+
token=API_KEY,
|
| 457 |
+
run_as_future=True,
|
| 458 |
+
)
|
| 459 |
return results
|
| 460 |
|
| 461 |
if prod:
|