Spaces:
Runtime error
Runtime error
Update Gradio app with multiple files
Browse files
models.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
import spaces
|
| 2 |
import torch
|
|
|
|
| 3 |
from diffusers import DiffusionPipeline
|
| 4 |
|
| 5 |
MODEL_ID = 'black-forest-labs/FLUX.1-dev'
|
|
@@ -7,7 +8,9 @@ MODEL_ID = 'black-forest-labs/FLUX.1-dev'
|
|
| 7 |
# Compile the model ahead-of-time for optimal performance
|
| 8 |
@spaces.GPU(duration=1500) # Maximum duration for compilation
|
| 9 |
def compile_transformer():
|
| 10 |
-
|
|
|
|
|
|
|
| 11 |
pipe.to('cuda')
|
| 12 |
|
| 13 |
# Capture example inputs for AoT compilation
|
|
@@ -26,7 +29,9 @@ def compile_transformer():
|
|
| 26 |
|
| 27 |
# Load and compile the model
|
| 28 |
def load_model():
|
| 29 |
-
|
|
|
|
|
|
|
| 30 |
pipe.to('cuda')
|
| 31 |
|
| 32 |
# Apply compiled transformer
|
|
|
|
| 1 |
import spaces
|
| 2 |
import torch
|
| 3 |
+
import os
|
| 4 |
from diffusers import DiffusionPipeline
|
| 5 |
|
| 6 |
MODEL_ID = 'black-forest-labs/FLUX.1-dev'
|
|
|
|
| 8 |
# Compile the model ahead-of-time for optimal performance
|
| 9 |
@spaces.GPU(duration=1500) # Maximum duration for compilation
|
| 10 |
def compile_transformer():
|
| 11 |
+
# Load model with HF token if available
|
| 12 |
+
token = os.getenv('HF_TOKEN')
|
| 13 |
+
pipe = DiffusionPipeline.from_pretrained(MODEL_ID, torch_dtype=torch.bfloat16, token=token)
|
| 14 |
pipe.to('cuda')
|
| 15 |
|
| 16 |
# Capture example inputs for AoT compilation
|
|
|
|
| 29 |
|
| 30 |
# Load and compile the model
|
| 31 |
def load_model():
|
| 32 |
+
# Load model with HF token if available
|
| 33 |
+
token = os.getenv('HF_TOKEN')
|
| 34 |
+
pipe = DiffusionPipeline.from_pretrained(MODEL_ID, torch_dtype=torch.bfloat16, token=token)
|
| 35 |
pipe.to('cuda')
|
| 36 |
|
| 37 |
# Apply compiled transformer
|