cosmicdream commited on
Commit
26490eb
·
1 Parent(s): c025d6e

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +73 -0
app.py ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @title
2
+ import multiprocessing
3
+ import torch
4
+ import os
5
+ from google.colab import output, drive
6
+ from psutil import virtual_memory
7
+ from pathlib import Path
8
+
9
+ ram_gb = round(virtual_memory().total / 1024**3, 1)
10
+
11
+ device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
12
+
13
+ from pynvml import *
14
+ nvmlInit()
15
+ h = nvmlDeviceGetHandleByIndex(0)
16
+ info = nvmlDeviceGetMemoryInfo(h)
17
+
18
+ from translatepy import Translator, Language
19
+ ts = Translator()
20
+ from deep_translator import DeeplTranslator, GoogleTranslator
21
+ from pathlib import Path
22
+ import csv
23
+ import logging
24
+ import requests
25
+
26
+ #swinir setup
27
+ %matplotlib inline
28
+ %config InlineBackend.figure_format = 'svg'
29
+ %config InlineBackend.rc = {'figure.figsize': (10.0, 10.0)}
30
+
31
+ !git clone -qq https://github.com/Lin-Sinorodin/SwinIR_wrapper.git
32
+ !pip install -qq timm
33
+ try:
34
+ from SwinIR_wrapper.SwinIR_wrapper import SwinIR_SR
35
+ except:
36
+ try:
37
+ import collections.abc as container_abcs
38
+ from SwinIR_wrapper.SwinIR_wrapper import SwinIR_SR
39
+ except:
40
+ pass
41
+
42
+ import cv2
43
+ import urllib.request
44
+ import matplotlib.pyplot as plt
45
+ import numpy
46
+
47
+ #@title
48
+ #!pip install rudalle==0.0.1rc4
49
+ #!git clone https://github.com/neverix/ru-dalle
50
+ !git clone https://github.com/ai-forever/ru-dalle
51
+ !mv -f ru-dalle/* ru-dalle/.git .
52
+ !rm -rf ru-dalle
53
+ #!git checkout better-caching
54
+ !git checkout develop
55
+ !pip install -e .
56
+ !pip install ruclip
57
+ !rm -rf output
58
+ !mkdir output
59
+ output.clear()
60
+
61
+ !rm -rf output
62
+ !mkdir output
63
+ output.clear()
64
+
65
+ # Import model
66
+ from rudalle.pipelines import generate_images, show, super_resolution, cherry_pick_by_ruclip
67
+ from rudalle import get_rudalle_model, get_tokenizer, get_vae, get_realesrgan
68
+ from rudalle.utils import seed_everything
69
+ from ruclip import load as get_ruclip
70
+
71
+ model = get_rudalle_model('Malevich', pretrained=True, fp16=True, device=device)
72
+ vae = get_vae().to('cuda')
73
+ tokenizer = get_tokenizer()