Yaron Koresh commited on
Commit
847d40e
·
verified ·
1 Parent(s): c2d6b49

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -589,7 +589,7 @@ def _summarize(text):
589
  toks = tokenizer.encode( prefix + text, return_tensors="pt", truncation=False)
590
  gen = model.generate(
591
  toks,
592
- length_penalty=0.1,
593
  num_beams=16,
594
  early_stopping=True,
595
  max_length=512
@@ -598,7 +598,7 @@ def _summarize(text):
598
  log(f'RET _summarize with ret as {ret}')
599
  return ret
600
 
601
- def summarize(text, max_words=10):
602
  log(f'CALL summarize')
603
 
604
  words = text.split()
@@ -1303,8 +1303,8 @@ def handle_generation(h,w,d):
1303
 
1304
  for line_index in range(len(d_lines)):
1305
  d_lines[line_index] = d_lines[line_index].strip()
1306
- if re.sub(r'[\.]$', '', d_lines[line_index]) == d_lines[line_index]:
1307
- d_lines[line_index] = d_lines[line_index].strip() + "."
1308
  d = " ".join(d_lines)
1309
 
1310
  d = re.sub(r"([ \t]){1,}", " ", d).lower().strip()
@@ -1314,11 +1314,11 @@ def handle_generation(h,w,d):
1314
  d = d if d == "" else translate(d)
1315
  d = re.sub(r"([ \t]){1,}", " ", d)
1316
  d = re.sub(r"(\. \.)", ".", d)
1317
- d = re.sub(r"[,]", ";", d).lower().strip()
1318
 
1319
  neg = f"Textual, Text, Blurry, Distorted, Exceptional, Irregular, Unusual, Shiny, Smoothed, Polished, Low Quality, Worst Quality, Normal Quality, Anime Quality, Paint Quality, Movie Quality."
1320
  q = "\""
1321
- pos = f'Realistic Real-Life Life-Like Convincing{ "." if d == "" else ": " + d }'
1322
 
1323
  print(f"""
1324
  Positive: {pos}
 
589
  toks = tokenizer.encode( prefix + text, return_tensors="pt", truncation=False)
590
  gen = model.generate(
591
  toks,
592
+ length_penalty=0.7,
593
  num_beams=16,
594
  early_stopping=True,
595
  max_length=512
 
598
  log(f'RET _summarize with ret as {ret}')
599
  return ret
600
 
601
+ def summarize(text, max_words=8):
602
  log(f'CALL summarize')
603
 
604
  words = text.split()
 
1303
 
1304
  for line_index in range(len(d_lines)):
1305
  d_lines[line_index] = d_lines[line_index].strip()
1306
+ if d_lines[line_index] != "" and re.sub(r'[\.]$', '', d_lines[line_index]) == d_lines[line_index]:
1307
+ d_lines[line_index] = d_lines[line_index] + "."
1308
  d = " ".join(d_lines)
1309
 
1310
  d = re.sub(r"([ \t]){1,}", " ", d).lower().strip()
 
1314
  d = d if d == "" else translate(d)
1315
  d = re.sub(r"([ \t]){1,}", " ", d)
1316
  d = re.sub(r"(\. \.)", ".", d)
1317
+ d = re.sub(r"[,]", ".", d).lower().strip()
1318
 
1319
  neg = f"Textual, Text, Blurry, Distorted, Exceptional, Irregular, Unusual, Shiny, Smoothed, Polished, Low Quality, Worst Quality, Normal Quality, Anime Quality, Paint Quality, Movie Quality."
1320
  q = "\""
1321
+ pos = f'Convincing Realism{ "." if d == "" else " from " + d }'
1322
 
1323
  print(f"""
1324
  Positive: {pos}