yaron123 commited on
Commit
af1bf66
·
1 Parent(s): d349975
Files changed (1) hide show
  1. app.py +3 -8
app.py CHANGED
@@ -31,7 +31,7 @@ from huggingface_hub import hf_hub_download
31
  from safetensors.torch import load_file, save_file
32
  from diffusers import FluxPipeline
33
  from PIL import Image, ImageDraw, ImageFont
34
- from transformers import PegasusForConditionalGeneration, PegasusTokenizerFast
35
  from refiners.fluxion.utils import manual_seed
36
  from refiners.foundationals.latent_diffusion import Solver, solvers
37
  from refiners.foundationals.latent_diffusion.stable_diffusion_1.multi_upscaler import (
@@ -502,9 +502,6 @@ image_pipe.enable_model_cpu_offload()
502
  image_pipe.enable_vae_slicing()
503
  image_pipe.enable_vae_tiling()
504
 
505
- pegasus_tokenizer = PegasusTokenizerFast.from_pretrained("google/pegasus-xsum")
506
- pegasus_model = PegasusForConditionalGeneration.from_pretrained("google/pegasus-xsum")
507
-
508
  # functionality
509
 
510
  def upscaler(
@@ -554,10 +551,8 @@ def summarize_text(
554
  text, max_length=16
555
  ):
556
  log(f'CALL summarize_text')
557
- summary = pegasus_tokenizer.decode( pegasus_model.generate(
558
- pegasus_tokenizer(text,return_tensors="pt").input_ids,
559
- max_length=max_length
560
- )[0], skip_special_tokens=True)
561
  log(f'RET summarize_text with summary as {summary}')
562
  return summary
563
 
 
31
  from safetensors.torch import load_file, save_file
32
  from diffusers import FluxPipeline
33
  from PIL import Image, ImageDraw, ImageFont
34
+ from transformers import pipeline
35
  from refiners.fluxion.utils import manual_seed
36
  from refiners.foundationals.latent_diffusion import Solver, solvers
37
  from refiners.foundationals.latent_diffusion.stable_diffusion_1.multi_upscaler import (
 
502
  image_pipe.enable_vae_slicing()
503
  image_pipe.enable_vae_tiling()
504
 
 
 
 
505
  # functionality
506
 
507
  def upscaler(
 
551
  text, max_length=16
552
  ):
553
  log(f'CALL summarize_text')
554
+ summ = pipeline("summarization", model="google/pegasus-xsum")
555
+ summary = summ("summarize: " + text)[0]["summary_text"]
 
 
556
  log(f'RET summarize_text with summary as {summary}')
557
  return summary
558