Spaces:
Running
on
Zero
Running
on
Zero
bugfix
Browse files
app.py
CHANGED
|
@@ -31,7 +31,7 @@ os.environ['PYTORCH_CUDA_ALLOC_CONF'] = 'max_split_size_mb:30'
|
|
| 31 |
login(token=HF_TOKEN)
|
| 32 |
|
| 33 |
MAX_SEED = np.iinfo(np.int32).max
|
| 34 |
-
IMAGE_SIZE =
|
| 35 |
|
| 36 |
# init
|
| 37 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
|
@@ -44,9 +44,7 @@ controlnet = FluxControlNetModel.from_pretrained(controlnet_model, torch_dtype=t
|
|
| 44 |
pipe = FluxControlNetInpaintPipeline.from_pretrained(base_model, controlnet=controlnet, torch_dtype=torch.bfloat16).to(device)
|
| 45 |
pipe.to("cuda")
|
| 46 |
torch.backends.cuda.matmul.allow_tf32 = True
|
| 47 |
-
|
| 48 |
-
pipe.vae.enable_slicing()
|
| 49 |
-
pipe.enable_model_cpu_offload() # for saving memory
|
| 50 |
|
| 51 |
control_mode_ids = {
|
| 52 |
"scribble_hed": 0,
|
|
@@ -144,7 +142,7 @@ def upload_image_to_r2(image, account_id, access_key, secret_key, bucket_name):
|
|
| 144 |
buffer.seek(0)
|
| 145 |
s3.upload_fileobj(buffer, bucket_name, image_file)
|
| 146 |
print("upload finish", image_file)
|
| 147 |
-
|
| 148 |
return image_file
|
| 149 |
|
| 150 |
|
|
@@ -176,6 +174,10 @@ def run_flux(
|
|
| 176 |
seed_slicer = random.randint(0, MAX_SEED)
|
| 177 |
generator = torch.Generator().manual_seed(seed_slicer)
|
| 178 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 179 |
with calculateDuration("run pipe"):
|
| 180 |
generated_image = pipe(
|
| 181 |
prompt=prompt,
|
|
|
|
| 31 |
login(token=HF_TOKEN)
|
| 32 |
|
| 33 |
MAX_SEED = np.iinfo(np.int32).max
|
| 34 |
+
IMAGE_SIZE = 1024
|
| 35 |
|
| 36 |
# init
|
| 37 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
|
|
|
| 44 |
pipe = FluxControlNetInpaintPipeline.from_pretrained(base_model, controlnet=controlnet, torch_dtype=torch.bfloat16).to(device)
|
| 45 |
pipe.to("cuda")
|
| 46 |
torch.backends.cuda.matmul.allow_tf32 = True
|
| 47 |
+
|
|
|
|
|
|
|
| 48 |
|
| 49 |
control_mode_ids = {
|
| 50 |
"scribble_hed": 0,
|
|
|
|
| 142 |
buffer.seek(0)
|
| 143 |
s3.upload_fileobj(buffer, bucket_name, image_file)
|
| 144 |
print("upload finish", image_file)
|
| 145 |
+
|
| 146 |
return image_file
|
| 147 |
|
| 148 |
|
|
|
|
| 174 |
seed_slicer = random.randint(0, MAX_SEED)
|
| 175 |
generator = torch.Generator().manual_seed(seed_slicer)
|
| 176 |
|
| 177 |
+
pipe.vae.enable_tiling()
|
| 178 |
+
pipe.vae.enable_slicing()
|
| 179 |
+
pipe.enable_model_cpu_offload() # for saving memory
|
| 180 |
+
|
| 181 |
with calculateDuration("run pipe"):
|
| 182 |
generated_image = pipe(
|
| 183 |
prompt=prompt,
|