Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,20 +1,19 @@
|
|
| 1 |
-
import
|
| 2 |
import torch
|
| 3 |
-
|
| 4 |
import re
|
| 5 |
-
import os
|
| 6 |
import yaml
|
| 7 |
import tempfile
|
| 8 |
import subprocess
|
| 9 |
from pathlib import Path
|
| 10 |
-
|
| 11 |
from dataclasses import dataclass
|
| 12 |
-
|
| 13 |
import gradio as gr
|
| 14 |
from src.flux.xflux_pipeline import XFluxPipeline
|
| 15 |
-
|
| 16 |
-
import os
|
| 17 |
from huggingface_hub import login
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
hf_token = os.getenv("HF_TOKEN")
|
| 20 |
if hf_token:
|
|
@@ -29,14 +28,13 @@ class Config:
|
|
| 29 |
offload: bool = False
|
| 30 |
share: bool = False
|
| 31 |
ckpt_dir: str = "."
|
| 32 |
-
|
| 33 |
xflux_pipeline = XFluxPipeline(Config.name, Config.device, Config.offload)
|
| 34 |
xflux_pipeline.to(device='cuda' if torch.cuda.is_available() else 'cpu')
|
| 35 |
|
| 36 |
@spaces.GPU
|
| 37 |
@torch.inference_mode()
|
| 38 |
def generate(**kwargs):
|
| 39 |
-
torch.multiprocessing.set_start_method('spawn', force=True)
|
| 40 |
return xflux_pipeline.gradio_generate(**kwargs)
|
| 41 |
|
| 42 |
def parse_args() -> Config:
|
|
|
|
| 1 |
+
import os
|
| 2 |
import torch
|
| 3 |
+
import spaces
|
| 4 |
import re
|
|
|
|
| 5 |
import yaml
|
| 6 |
import tempfile
|
| 7 |
import subprocess
|
| 8 |
from pathlib import Path
|
|
|
|
| 9 |
from dataclasses import dataclass
|
|
|
|
| 10 |
import gradio as gr
|
| 11 |
from src.flux.xflux_pipeline import XFluxPipeline
|
|
|
|
|
|
|
| 12 |
from huggingface_hub import login
|
| 13 |
+
import multiprocessing
|
| 14 |
+
|
| 15 |
+
# Set the multiprocessing start method globally
|
| 16 |
+
multiprocessing.set_start_method('spawn', force=True)
|
| 17 |
|
| 18 |
hf_token = os.getenv("HF_TOKEN")
|
| 19 |
if hf_token:
|
|
|
|
| 28 |
offload: bool = False
|
| 29 |
share: bool = False
|
| 30 |
ckpt_dir: str = "."
|
| 31 |
+
|
| 32 |
xflux_pipeline = XFluxPipeline(Config.name, Config.device, Config.offload)
|
| 33 |
xflux_pipeline.to(device='cuda' if torch.cuda.is_available() else 'cpu')
|
| 34 |
|
| 35 |
@spaces.GPU
|
| 36 |
@torch.inference_mode()
|
| 37 |
def generate(**kwargs):
|
|
|
|
| 38 |
return xflux_pipeline.gradio_generate(**kwargs)
|
| 39 |
|
| 40 |
def parse_args() -> Config:
|