Spaces:
Sleeping
Sleeping
Yaron Koresh
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -451,8 +451,8 @@ MAX_SEED = np.iinfo(np.int32).max
|
|
451 |
# precision data
|
452 |
|
453 |
seq=512
|
454 |
-
image_steps=
|
455 |
-
img_accu=
|
456 |
|
457 |
# ui data
|
458 |
|
@@ -528,7 +528,7 @@ torch.cuda.empty_cache()
|
|
528 |
def upscaler(
|
529 |
input_image: Image.Image,
|
530 |
prompt: str = "Masterpiece, Best Quality, Hyper-Realistic, Super-Realistic, Natural, Reasonable, Logical.",
|
531 |
-
negative_prompt: str = "Blurry, Distorted, Exceptional, Irregular, Unusual, Shiny, Smoothed, Polished, Low Quality, Worst Quality, Normal Quality, Anime Quality,
|
532 |
seed: int = random.randint(0, MAX_SEED),
|
533 |
upscale_factor: int = 2,
|
534 |
controlnet_scale: float = 0.6,
|
@@ -594,8 +594,8 @@ def _summarize(text):
|
|
594 |
toks = tokenizer.encode( prefix + text, return_tensors="pt", truncation=False)
|
595 |
gen = model.generate(
|
596 |
toks,
|
597 |
-
length_penalty=
|
598 |
-
num_beams=
|
599 |
early_stopping=True,
|
600 |
max_length=512
|
601 |
)
|
@@ -603,7 +603,7 @@ def _summarize(text):
|
|
603 |
log(f'RET _summarize with ret as {ret}')
|
604 |
return ret
|
605 |
|
606 |
-
def summarize(text,
|
607 |
log(f'CALL summarize')
|
608 |
|
609 |
words = text.split()
|
@@ -620,11 +620,12 @@ def summarize(text, max_len=400):
|
|
620 |
text = summ
|
621 |
words_length = len(text.split())
|
622 |
|
623 |
-
while
|
624 |
summ = _summarize(text)
|
625 |
if summ == text:
|
626 |
return text
|
627 |
text = summ
|
|
|
628 |
|
629 |
log(f'RET summarize with text as {text}')
|
630 |
return text
|
@@ -1319,9 +1320,9 @@ def handle_generation(h,w,d):
|
|
1319 |
d = re.sub(r"([ \t]){1,}", " ", d)
|
1320 |
d = re.sub(r"(\. \.)", ".", d).lower().strip()
|
1321 |
|
1322 |
-
neg = f"Textual, Text, Blurry, Distorted, Exceptional, Irregular, Unusual, Shiny, Smoothed, Polished, Low Quality, Worst Quality, Normal Quality, Anime Quality,
|
1323 |
q = "\""
|
1324 |
-
pos = f'Masterpiece, Best Quality, Hyper-Realistic, Super-Realistic, Natural, Reasonable, Logical
|
1325 |
|
1326 |
print(f"""
|
1327 |
Positive: {pos}
|
|
|
451 |
# precision data
|
452 |
|
453 |
seq=512
|
454 |
+
image_steps=50
|
455 |
+
img_accu=8.5
|
456 |
|
457 |
# ui data
|
458 |
|
|
|
528 |
def upscaler(
|
529 |
input_image: Image.Image,
|
530 |
prompt: str = "Masterpiece, Best Quality, Hyper-Realistic, Super-Realistic, Natural, Reasonable, Logical.",
|
531 |
+
negative_prompt: str = "Blurry, Distorted, Exceptional, Irregular, Unusual, Shiny, Smoothed, Polished, Low Quality, Worst Quality, Normal Quality, Anime Quality, Paint Quality, Movie Quality.",
|
532 |
seed: int = random.randint(0, MAX_SEED),
|
533 |
upscale_factor: int = 2,
|
534 |
controlnet_scale: float = 0.6,
|
|
|
594 |
toks = tokenizer.encode( prefix + text, return_tensors="pt", truncation=False)
|
595 |
gen = model.generate(
|
596 |
toks,
|
597 |
+
length_penalty=0.1,
|
598 |
+
num_beams=16,
|
599 |
early_stopping=True,
|
600 |
max_length=512
|
601 |
)
|
|
|
603 |
log(f'RET _summarize with ret as {ret}')
|
604 |
return ret
|
605 |
|
606 |
+
def summarize(text, max_words=20):
|
607 |
log(f'CALL summarize')
|
608 |
|
609 |
words = text.split()
|
|
|
620 |
text = summ
|
621 |
words_length = len(text.split())
|
622 |
|
623 |
+
while words_length > max_words:
|
624 |
summ = _summarize(text)
|
625 |
if summ == text:
|
626 |
return text
|
627 |
text = summ
|
628 |
+
words_length = len(text.split())
|
629 |
|
630 |
log(f'RET summarize with text as {text}')
|
631 |
return text
|
|
|
1320 |
d = re.sub(r"([ \t]){1,}", " ", d)
|
1321 |
d = re.sub(r"(\. \.)", ".", d).lower().strip()
|
1322 |
|
1323 |
+
neg = f"Textual, Text, Blurry, Distorted, Exceptional, Irregular, Unusual, Shiny, Smoothed, Polished, Low Quality, Worst Quality, Normal Quality, Anime Quality, Paint Quality, Movie Quality."
|
1324 |
q = "\""
|
1325 |
+
pos = f'Masterpiece, Best Quality, Hyper-Realistic, Super-Realistic, Natural, Reasonable, Logical{ "." if d == "" else ". " + d }'
|
1326 |
|
1327 |
print(f"""
|
1328 |
Positive: {pos}
|