Spaces:
Running
on
Zero
Running
on
Zero
Commit
·
14626ab
1
Parent(s):
aaa0ff6
Remove unused image enhancement functions to streamline image processing
Browse files
app.py
CHANGED
@@ -19,7 +19,7 @@ import cv2
|
|
19 |
import numpy as np
|
20 |
import torch
|
21 |
import torch.nn.functional as F
|
22 |
-
from PIL import Image
|
23 |
import PIL.Image as PImage
|
24 |
from torchvision.transforms.functional import to_tensor
|
25 |
from transformers import AutoTokenizer, T5EncoderModel, T5TokenizerFast
|
@@ -66,16 +66,6 @@ def encode_prompt(text_tokenizer, text_encoder, prompt):
|
|
66 |
text_cond_tuple = (kv_compact, lens, cu_seqlens_k, Ltext)
|
67 |
return text_cond_tuple
|
68 |
|
69 |
-
def enhance_image(image):
|
70 |
-
for t in range(1):
|
71 |
-
contrast_image = image.copy()
|
72 |
-
contrast_enhancer = ImageEnhance.Contrast(contrast_image)
|
73 |
-
contrast_image = contrast_enhancer.enhance(1.05) # 增强对比度
|
74 |
-
color_image = contrast_image.copy()
|
75 |
-
color_enhancer = ImageEnhance.Color(color_image)
|
76 |
-
color_image = color_enhancer.enhance(1.05) # 增强饱和度
|
77 |
-
return color_image
|
78 |
-
|
79 |
def gen_one_img(
|
80 |
infinity_test,
|
81 |
vae,
|
@@ -141,12 +131,6 @@ def gen_one_img(
|
|
141 |
img = img_list[0]
|
142 |
return img
|
143 |
|
144 |
-
def get_prompt_id(prompt):
|
145 |
-
md5 = hashlib.md5()
|
146 |
-
md5.update(prompt.encode('utf-8'))
|
147 |
-
prompt_id = md5.hexdigest()
|
148 |
-
return prompt_id
|
149 |
-
|
150 |
def save_slim_model(infinity_model_path, save_file=None, device='cpu', key='gpt_fsdp'):
|
151 |
print('[Save slim model]')
|
152 |
full_ckpt = torch.load(infinity_model_path, map_location=device)
|
|
|
19 |
import numpy as np
|
20 |
import torch
|
21 |
import torch.nn.functional as F
|
22 |
+
from PIL import Image
|
23 |
import PIL.Image as PImage
|
24 |
from torchvision.transforms.functional import to_tensor
|
25 |
from transformers import AutoTokenizer, T5EncoderModel, T5TokenizerFast
|
|
|
66 |
text_cond_tuple = (kv_compact, lens, cu_seqlens_k, Ltext)
|
67 |
return text_cond_tuple
|
68 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
def gen_one_img(
|
70 |
infinity_test,
|
71 |
vae,
|
|
|
131 |
img = img_list[0]
|
132 |
return img
|
133 |
|
|
|
|
|
|
|
|
|
|
|
|
|
134 |
def save_slim_model(infinity_model_path, save_file=None, device='cpu', key='gpt_fsdp'):
|
135 |
print('[Save slim model]')
|
136 |
full_ckpt = torch.load(infinity_model_path, map_location=device)
|