Spaces:
Runtime error
Runtime error
GRADIO_TEMP_DIR fix
#6
by
6Morpheus6
- opened
app.py
CHANGED
|
@@ -7,6 +7,7 @@ import gradio as gr
|
|
| 7 |
import numpy as np
|
| 8 |
import PIL
|
| 9 |
import gc
|
|
|
|
| 10 |
#import spaces
|
| 11 |
import torch
|
| 12 |
from diffusers import LCMScheduler
|
|
@@ -68,6 +69,10 @@ pipe = StableDiffusionXLInstantIDPipeline.from_pretrained(
|
|
| 68 |
safety_checker=None,
|
| 69 |
feature_extractor=None,
|
| 70 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
#pipe.cuda()
|
| 72 |
if os.environ.get("MODE") == "Default":
|
| 73 |
print("Default")
|
|
@@ -312,7 +317,7 @@ def generate_image(
|
|
| 312 |
generator=generator,
|
| 313 |
).images
|
| 314 |
|
| 315 |
-
gradio_temp_dir = os.environ
|
| 316 |
temp_file_path = os.path.join(gradio_temp_dir, "image.png")
|
| 317 |
images[0].save(temp_file_path, format="PNG")
|
| 318 |
print(f"Image saved in: {temp_file_path}")
|
|
|
|
| 7 |
import numpy as np
|
| 8 |
import PIL
|
| 9 |
import gc
|
| 10 |
+
import tempfile
|
| 11 |
#import spaces
|
| 12 |
import torch
|
| 13 |
from diffusers import LCMScheduler
|
|
|
|
| 69 |
safety_checker=None,
|
| 70 |
feature_extractor=None,
|
| 71 |
)
|
| 72 |
+
|
| 73 |
+
num_inference_steps = 30
|
| 74 |
+
guidance_scale = 5
|
| 75 |
+
|
| 76 |
#pipe.cuda()
|
| 77 |
if os.environ.get("MODE") == "Default":
|
| 78 |
print("Default")
|
|
|
|
| 317 |
generator=generator,
|
| 318 |
).images
|
| 319 |
|
| 320 |
+
gradio_temp_dir = os.environ.get('GRADIO_TEMP_DIR', tempfile.gettempdir())
|
| 321 |
temp_file_path = os.path.join(gradio_temp_dir, "image.png")
|
| 322 |
images[0].save(temp_file_path, format="PNG")
|
| 323 |
print(f"Image saved in: {temp_file_path}")
|