Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -6,7 +6,7 @@ import gradio as gr
|
|
6 |
import numpy as np
|
7 |
import torch
|
8 |
from PIL import Image
|
9 |
-
from diffusers import EDMEulerScheduler, StableDiffusionXLInstructPix2PixPipeline
|
10 |
from huggingface_hub import hf_hub_download, InferenceClient
|
11 |
from diffusers import DiffusionPipeline
|
12 |
|
@@ -39,12 +39,20 @@ def set_timesteps_patched(self, num_inference_steps: int, device = None):
|
|
39 |
self.sigmas = self.sigmas.to("cpu")
|
40 |
|
41 |
# Image Editor
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
edit_file = hf_hub_download(repo_id="stabilityai/cosxl", filename="cosxl_edit.safetensors")
|
43 |
EDMEulerScheduler.set_timesteps = set_timesteps_patched
|
44 |
pipe_edit = StableDiffusionXLInstructPix2PixPipeline.from_single_file( edit_file, num_in_channels=8, is_cosxl_edit=True, vae=vae, torch_dtype=torch.float16 )
|
45 |
pipe_edit.scheduler = EDMEulerScheduler(sigma_min=0.002, sigma_max=120.0, sigma_data=1.0, prediction_type="v_prediction")
|
46 |
pipe_edit.to("cuda")
|
47 |
|
|
|
|
|
48 |
client1 = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
|
49 |
system_instructions1 = "<|system|>\nAct as Image Prompt Generation expert, Your task is to modify prompt by USER to more better and detailed prompt for Image Generation. \n Ensure the prompt is deatiled, yet descriptive to generate an exceptional image that meets the user's expectations. \n Your task is to reply with final optimized prompt only. Reply with optimized prompt only.\n<|user|>\n"
|
50 |
|
|
|
6 |
import numpy as np
|
7 |
import torch
|
8 |
from PIL import Image
|
9 |
+
from diffusers import EDMEulerScheduler, StableDiffusionXLInstructPix2PixPipeline, StableDiffusionXLImg2ImgPipeline, AutoencoderKL
|
10 |
from huggingface_hub import hf_hub_download, InferenceClient
|
11 |
from diffusers import DiffusionPipeline
|
12 |
|
|
|
39 |
self.sigmas = self.sigmas.to("cpu")
|
40 |
|
41 |
# Image Editor
|
42 |
+
|
43 |
+
vae = AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix", torch_dtype=torch.float16)
|
44 |
+
|
45 |
+
refiner = StableDiffusionXLImg2ImgPipeline.from_pretrained("stabilityai/stable-diffusion-xl-refiner-1.0", vae=vae, torch_dtype=torch.float16, use_safetensors=True, variant="fp16")
|
46 |
+
refiner.to("cuda")
|
47 |
+
|
48 |
edit_file = hf_hub_download(repo_id="stabilityai/cosxl", filename="cosxl_edit.safetensors")
|
49 |
EDMEulerScheduler.set_timesteps = set_timesteps_patched
|
50 |
pipe_edit = StableDiffusionXLInstructPix2PixPipeline.from_single_file( edit_file, num_in_channels=8, is_cosxl_edit=True, vae=vae, torch_dtype=torch.float16 )
|
51 |
pipe_edit.scheduler = EDMEulerScheduler(sigma_min=0.002, sigma_max=120.0, sigma_data=1.0, prediction_type="v_prediction")
|
52 |
pipe_edit.to("cuda")
|
53 |
|
54 |
+
|
55 |
+
|
56 |
client1 = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
|
57 |
system_instructions1 = "<|system|>\nAct as Image Prompt Generation expert, Your task is to modify prompt by USER to more better and detailed prompt for Image Generation. \n Ensure the prompt is deatiled, yet descriptive to generate an exceptional image that meets the user's expectations. \n Your task is to reply with final optimized prompt only. Reply with optimized prompt only.\n<|user|>\n"
|
58 |
|