Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -109,7 +109,7 @@ def load_and_prepare_model(model_id):
|
|
109 |
"ford442/RealVisXL_V5.0_BF16": torch.bfloat16,
|
110 |
}
|
111 |
dtype = model_dtypes.get(model_id, torch.bfloat16) # Default to float32 if not found
|
112 |
-
vae = AutoencoderKL.from_pretrained("ford442/sdxl-vae-bf16", torch_dtype=torch.bfloat16,safety_checker=None)
|
113 |
pipe = StableDiffusionXLPipeline.from_pretrained(
|
114 |
model_id,
|
115 |
torch_dtype=torch.bfloat16,
|
@@ -149,13 +149,12 @@ def randomize_seed_fn(seed: int, randomize_seed: bool) -> int:
|
|
149 |
seed = random.randint(0, MAX_SEED)
|
150 |
return seed
|
151 |
|
152 |
-
|
153 |
-
|
154 |
GPU_DURATION_OPTIONS = {
|
|
|
155 |
"Short (45s)": 45,
|
156 |
-
"
|
157 |
"Medium (80s)": 80,
|
158 |
-
"
|
159 |
"Long (120s)": 120,
|
160 |
"Long (140s)": 140,
|
161 |
}
|
@@ -163,7 +162,7 @@ GPU_DURATION_OPTIONS = {
|
|
163 |
def set_gpu_duration(duration_choice):
|
164 |
os.environ["GPU_DURATION"] = str(GPU_DURATION_OPTIONS[duration_choice])
|
165 |
|
166 |
-
@spaces.GPU(duration=int(os.getenv("GPU_DURATION", "
|
167 |
def generate(
|
168 |
model_choice: str,
|
169 |
prompt: str,
|
@@ -320,7 +319,7 @@ with gr.Blocks(css=css, theme="bethecloud/storj_theme") as demo:
|
|
320 |
gpu_duration = gr.Dropdown(
|
321 |
label="GPU Duration",
|
322 |
choices=list(GPU_DURATION_OPTIONS.keys()),
|
323 |
-
value="Medium (
|
324 |
)
|
325 |
|
326 |
gpu_duration.change(fn=set_gpu_duration, inputs=gpu_duration, outputs=[])
|
|
|
109 |
"ford442/RealVisXL_V5.0_BF16": torch.bfloat16,
|
110 |
}
|
111 |
dtype = model_dtypes.get(model_id, torch.bfloat16) # Default to float32 if not found
|
112 |
+
vae = AutoencoderKL.from_pretrained("ford442/sdxl-vae-bf16", torch_dtype=torch.bfloat16,safety_checker=None)
|
113 |
pipe = StableDiffusionXLPipeline.from_pretrained(
|
114 |
model_id,
|
115 |
torch_dtype=torch.bfloat16,
|
|
|
149 |
seed = random.randint(0, MAX_SEED)
|
150 |
return seed
|
151 |
|
|
|
|
|
152 |
GPU_DURATION_OPTIONS = {
|
153 |
+
"Short (25s)": 25,
|
154 |
"Short (45s)": 45,
|
155 |
+
"Medium (60s)": 60,
|
156 |
"Medium (80s)": 80,
|
157 |
+
"Long (100s)": 100,
|
158 |
"Long (120s)": 120,
|
159 |
"Long (140s)": 140,
|
160 |
}
|
|
|
162 |
def set_gpu_duration(duration_choice):
|
163 |
os.environ["GPU_DURATION"] = str(GPU_DURATION_OPTIONS[duration_choice])
|
164 |
|
165 |
+
@spaces.GPU(duration=int(os.getenv("GPU_DURATION", "60"))) # Dynamic duration
|
166 |
def generate(
|
167 |
model_choice: str,
|
168 |
prompt: str,
|
|
|
319 |
gpu_duration = gr.Dropdown(
|
320 |
label="GPU Duration",
|
321 |
choices=list(GPU_DURATION_OPTIONS.keys()),
|
322 |
+
value="Medium (60s)" # Default value
|
323 |
)
|
324 |
|
325 |
gpu_duration.change(fn=set_gpu_duration, inputs=gpu_duration, outputs=[])
|