Spaces:
Running
on
Zero
Running
on
Zero
Delete feifeilib/feifeiimgtoimg.py
Browse files- feifeilib/feifeiimgtoimg.py +0 -35
feifeilib/feifeiimgtoimg.py
DELETED
@@ -1,35 +0,0 @@
|
|
1 |
-
import gradio as gr
|
2 |
-
from PIL import Image
|
3 |
-
import numpy as np
|
4 |
-
import random
|
5 |
-
import spaces
|
6 |
-
import torch.nn.functional as F
|
7 |
-
import torch
|
8 |
-
from diffusers import FluxImg2ImgPipeline
|
9 |
-
from diffusers.utils import load_image
|
10 |
-
|
11 |
-
dtype = torch.bfloat16
|
12 |
-
device = "cuda" if torch.cuda.is_available() else "cpu"
|
13 |
-
img_pipe = FluxImg2ImgPipeline.from_pretrained("aifeifei798/shuttle-3-diffusion",
|
14 |
-
torch_dtype=dtype)
|
15 |
-
img_pipe = img_pipe.to(device)
|
16 |
-
MAX_SEED = np.iinfo(np.int32).max
|
17 |
-
|
18 |
-
@spaces.GPU()
|
19 |
-
def feifeiimgtoimg(img_in_result,
|
20 |
-
prompt,
|
21 |
-
progress=gr.Progress(track_tqdm=True)):
|
22 |
-
seed = random.randint(0, MAX_SEED)
|
23 |
-
generator = torch.Generator().manual_seed(seed)
|
24 |
-
init_image = load_image(img_in_result)
|
25 |
-
images = img_pipe(prompt="",
|
26 |
-
prompt_2=prompt,
|
27 |
-
image=init_image,
|
28 |
-
width=896,
|
29 |
-
height=1152,
|
30 |
-
num_inference_steps=4,
|
31 |
-
strength=0.95,
|
32 |
-
generator=generator,
|
33 |
-
utput_type="pil",
|
34 |
-
guidance_scale=3.5).images[0]
|
35 |
-
return images
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|