Update main.py
Browse files
main.py
CHANGED
@@ -2,6 +2,29 @@ import pickle
|
|
2 |
import random
|
3 |
import numpy as np
|
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
with open('models.pickle', 'rb')as f:
|
6 |
models = pickle.load(f)
|
7 |
|
|
|
2 |
import random
|
3 |
import numpy as np
|
4 |
|
5 |
+
import os
|
6 |
+
import wget
|
7 |
+
from zipfile import ZipFile
|
8 |
+
|
9 |
+
|
10 |
+
def download_model(force = False):
|
11 |
+
if force == True: print('downloading model file size is 108 MB so it may take some time to complete...')
|
12 |
+
try:
|
13 |
+
url = "https://huggingface.co/thefcraft/prompt-generator-stable-diffusion/resolve/main/models.pickle.zip"
|
14 |
+
if force == True:
|
15 |
+
with open("models.pickle.zip", 'w'): pass
|
16 |
+
wget.download(url, "models.pickle.zip")
|
17 |
+
if not os.path.exists('models.pickle.zip'): wget.download(url, "models.pickle.zip")
|
18 |
+
print('Download zip file now extracting model')
|
19 |
+
with ZipFile("models.pickle.zip", 'r') as zObject: zObject.extractall()
|
20 |
+
print('extracted model .. now all done')
|
21 |
+
return True
|
22 |
+
except:
|
23 |
+
if force == False: return download_model(force=True)
|
24 |
+
print('Something went wrong\ndownload model via link: `https://huggingface.co/thefcraft/prompt-generator-stable-diffusion/tree/main`')
|
25 |
+
|
26 |
+
if not os.path.exists('models.pickle'): download_model()
|
27 |
+
|
28 |
with open('models.pickle', 'rb')as f:
|
29 |
models = pickle.load(f)
|
30 |
|