Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -1,15 +1,18 @@
|
|
1 |
import spaces # Import this first to avoid CUDA initialization issues
|
2 |
import os
|
3 |
import gradio as gr
|
|
|
4 |
import json
|
5 |
import torch
|
6 |
import random
|
7 |
import time
|
8 |
from PIL import Image
|
9 |
-
from diffusers import DiffusionPipeline
|
|
|
10 |
|
11 |
# Define the device
|
12 |
-
|
|
|
13 |
|
14 |
# Use the 'waffles' environment variable as the access token
|
15 |
hf_token = os.getenv('waffles')
|
@@ -24,13 +27,10 @@ with open('loras.json', 'r') as f:
|
|
24 |
|
25 |
# Initialize the base model with authentication and specify the device
|
26 |
# Initialize the base model with authentication and specify the device
|
27 |
-
pipe = DiffusionPipeline.from_pretrained(
|
28 |
-
"black-forest-labs/FLUX.1-schnell",
|
29 |
-
torch_dtype=torch.bfloat16,
|
30 |
-
token=hf_token
|
31 |
-
).to(device)
|
32 |
|
33 |
-
MAX_SEED =
|
|
|
34 |
|
35 |
class calculateDuration:
|
36 |
def __init__(self, activity_name=""):
|
|
|
1 |
import spaces # Import this first to avoid CUDA initialization issues
|
2 |
import os
|
3 |
import gradio as gr
|
4 |
+
import numpy as np
|
5 |
import json
|
6 |
import torch
|
7 |
import random
|
8 |
import time
|
9 |
from PIL import Image
|
10 |
+
from diffusers import DiffusionPipeline, FlowMatchEulerDiscreteScheduler, FluxTransformer2DModel
|
11 |
+
from transformers import CLIPTextModel, CLIPTokenizer,T5EncoderModel, T5TokenizerFast
|
12 |
|
13 |
# Define the device
|
14 |
+
dtype = torch.bfloat16
|
15 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
16 |
|
17 |
# Use the 'waffles' environment variable as the access token
|
18 |
hf_token = os.getenv('waffles')
|
|
|
27 |
|
28 |
# Initialize the base model with authentication and specify the device
|
29 |
# Initialize the base model with authentication and specify the device
|
30 |
+
pipe = DiffusionPipeline.from_pretrained("sayakpaul/FLUX.1-merged", torch_dtype=dtype, token=hf_token).to(device)
|
|
|
|
|
|
|
|
|
31 |
|
32 |
+
MAX_SEED = np.iinfo(np.int32).max
|
33 |
+
MAX_IMAGE_SIZE = 2048
|
34 |
|
35 |
class calculateDuration:
|
36 |
def __init__(self, activity_name=""):
|