Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,13 +1,14 @@
|
|
1 |
-
import random
|
2 |
import gradio as gr
|
3 |
import numpy as np
|
|
|
4 |
import spaces
|
|
|
5 |
import torch
|
6 |
import torchvision.transforms as transforms
|
7 |
from PIL import Image
|
8 |
from torchmetrics.functional.image import structural_similarity_index_measure as ssim
|
9 |
from transformers import CLIPModel, CLIPProcessor
|
10 |
-
|
11 |
|
12 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
13 |
model_path = "czl/stable-diffusion-v1-5"
|
@@ -90,7 +91,6 @@ def infer(
|
|
90 |
).to(device)
|
91 |
embed_pairs = zip(interpolated_prompt_embeds, interpolated_negative_prompts_embeds)
|
92 |
embed_pairs_list = list(embed_pairs)
|
93 |
-
# offset step by -1
|
94 |
prompt_embeds, negative_prompt_embeds = embed_pairs_list[interpolation_step - 1]
|
95 |
preprocess_input = transforms.Compose(
|
96 |
[transforms.ToTensor(), transforms.Resize((512, 512))]
|
@@ -117,7 +117,6 @@ def infer(
|
|
117 |
return image, seed, "Unsafe content detected", "Unsafe content detected"
|
118 |
else:
|
119 |
image = images_list.images[0]
|
120 |
-
|
121 |
pred_image = transforms.ToTensor()(image).unsqueeze(0)
|
122 |
ssim_score = ssim(pred_image, input_img_tensor).item()
|
123 |
real_inputs = clip_processor(
|
|
|
|
|
1 |
import gradio as gr
|
2 |
import numpy as np
|
3 |
+
import random
|
4 |
import spaces
|
5 |
+
import sourcecode
|
6 |
import torch
|
7 |
import torchvision.transforms as transforms
|
8 |
from PIL import Image
|
9 |
from torchmetrics.functional.image import structural_similarity_index_measure as ssim
|
10 |
from transformers import CLIPModel, CLIPProcessor
|
11 |
+
|
12 |
|
13 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
14 |
model_path = "czl/stable-diffusion-v1-5"
|
|
|
91 |
).to(device)
|
92 |
embed_pairs = zip(interpolated_prompt_embeds, interpolated_negative_prompts_embeds)
|
93 |
embed_pairs_list = list(embed_pairs)
|
|
|
94 |
prompt_embeds, negative_prompt_embeds = embed_pairs_list[interpolation_step - 1]
|
95 |
preprocess_input = transforms.Compose(
|
96 |
[transforms.ToTensor(), transforms.Resize((512, 512))]
|
|
|
117 |
return image, seed, "Unsafe content detected", "Unsafe content detected"
|
118 |
else:
|
119 |
image = images_list.images[0]
|
|
|
120 |
pred_image = transforms.ToTensor()(image).unsqueeze(0)
|
121 |
ssim_score = ssim(pred_image, input_img_tensor).item()
|
122 |
real_inputs = clip_processor(
|