cosmicdream commited on
Commit
0424af2
1 Parent(s): 02f5ec0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -2
app.py CHANGED
@@ -21,15 +21,34 @@ import requests
21
  from rudalle.pipelines import generate_images, show, super_resolution, cherry_pick_by_ruclip
22
  from rudalle import get_rudalle_model, get_tokenizer, get_vae, get_realesrgan
23
  from rudalle.utils import seed_everything
24
- from ruclip import load as get_ruclip
25
 
26
  # prepare models:
27
  device = 'cuda'
 
28
  model = get_rudalle_model('Malevich', pretrained=True, fp16=True, device=device)
29
  tokenizer = get_tokenizer()
30
  vae = get_vae(dwt=True).to(device)
31
 
32
- #device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
 
34
 
35
  pipeline = pipeline(task="image-classification", model="julien-c/hotdog-not-hotdog")
 
21
  from rudalle.pipelines import generate_images, show, super_resolution, cherry_pick_by_ruclip
22
  from rudalle import get_rudalle_model, get_tokenizer, get_vae, get_realesrgan
23
  from rudalle.utils import seed_everything
24
+ #from ruclip import load as get_ruclip
25
 
26
  # prepare models:
27
  device = 'cuda'
28
+ #device = torch.device("cuda:0" if torch.cuda.is_available() else "CPU")
29
  model = get_rudalle_model('Malevich', pretrained=True, fp16=True, device=device)
30
  tokenizer = get_tokenizer()
31
  vae = get_vae(dwt=True).to(device)
32
 
33
+ # pipeline utils:
34
+ #TEST--------
35
+ realesrgan = get_realesrgan('x2', device=device)
36
+ clip, processor = ruclip.load('ruclip-vit-base-patch32-384', device=device)
37
+ clip_predictor = ruclip.Predictor(clip, processor, device, bs=8)
38
+ text = 'радуга на фоне ночного города'
39
+
40
+ seed_everything(42)
41
+ pil_images = []
42
+ scores = []
43
+ for top_k, top_p, images_num in [
44
+ (2048, 0.995, 24),
45
+ ]:
46
+ _pil_images, _scores = generate_images(text, tokenizer, dalle, vae, top_k=top_k, images_num=images_num, bs=8, top_p=top_p)
47
+ pil_images += _pil_images
48
+ scores += _scores
49
+
50
+ show(pil_images, 6)
51
+ #TEST--------
52
 
53
 
54
  pipeline = pipeline(task="image-classification", model="julien-c/hotdog-not-hotdog")