Spaces:
Running on Zero
Running on Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,8 +1,11 @@
|
|
| 1 |
import os
|
|
|
|
|
|
|
| 2 |
import io
|
| 3 |
import gradio as gr
|
| 4 |
import numpy as np
|
| 5 |
import random
|
|
|
|
| 6 |
import torch
|
| 7 |
from diffusers import Flux2Pipeline, Flux2Transformer2DModel
|
| 8 |
from diffusers import BitsAndBytesConfig as DiffBitsAndBytesConfig
|
|
@@ -12,7 +15,8 @@ import json
|
|
| 12 |
import base64
|
| 13 |
from huggingface_hub import InferenceClient
|
| 14 |
|
| 15 |
-
# spaces
|
|
|
|
| 16 |
|
| 17 |
dtype = torch.bfloat16
|
| 18 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
|
@@ -159,9 +163,9 @@ def update_dimensions_from_image(image_list):
|
|
| 159 |
|
| 160 |
return new_width, new_height
|
| 161 |
|
| 162 |
-
# โ ๏ธ
|
| 163 |
-
#
|
| 164 |
-
|
| 165 |
def generate_image(generation_args):
|
| 166 |
"""
|
| 167 |
generation_args = {
|
|
|
|
| 1 |
import os
|
| 2 |
+
import subprocess
|
| 3 |
+
import sys
|
| 4 |
import io
|
| 5 |
import gradio as gr
|
| 6 |
import numpy as np
|
| 7 |
import random
|
| 8 |
+
import spaces
|
| 9 |
import torch
|
| 10 |
from diffusers import Flux2Pipeline, Flux2Transformer2DModel
|
| 11 |
from diffusers import BitsAndBytesConfig as DiffBitsAndBytesConfig
|
|
|
|
| 15 |
import base64
|
| 16 |
from huggingface_hub import InferenceClient
|
| 17 |
|
| 18 |
+
# spaces ์ต์ ๋ฒ์ ์ผ๋ก ์
๊ทธ๋ ์ด๋ (0.43.0์ ๋ฒ๊ทธ ์์)
|
| 19 |
+
subprocess.check_call([sys.executable, "-m", "pip", "install", "--upgrade", "spaces"])
|
| 20 |
|
| 21 |
dtype = torch.bfloat16
|
| 22 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
|
|
|
| 163 |
|
| 164 |
return new_width, new_height
|
| 165 |
|
| 166 |
+
# โ ๏ธ spaces.GPU ๋ฐ์ฝ๋ ์ดํฐ๋ ํ๋ผ๋ฏธํฐ ๊ฐ์ ์ ํ์ด ์์
|
| 167 |
+
# ๋ชจ๋ ํ๋ผ๋ฏธํฐ๋ฅผ ํ๋์ dict๋ก ๋ฌถ์ด์ ์ ๋ฌ
|
| 168 |
+
@spaces.GPU
|
| 169 |
def generate_image(generation_args):
|
| 170 |
"""
|
| 171 |
generation_args = {
|