Josh Cox
commited on
Commit
·
fafaeda
1
Parent(s):
74b3e81
32
Browse files- artist_lib.py +6 -4
artist_lib.py
CHANGED
@@ -88,6 +88,7 @@ def generate_tone(note, octave, duration):
|
|
88 |
|
89 |
def draw(inp, this_model, force_new):
|
90 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
|
|
91 |
drawing = inp
|
92 |
if this_model == "stable-diffusion-2":
|
93 |
this_model_addr = "stabilityai/stable-diffusion-2"
|
@@ -110,7 +111,7 @@ def draw(inp, this_model, force_new):
|
|
110 |
print("found drawing ", drawing_filename)
|
111 |
return Image.open(drawing_filename)
|
112 |
print("generating drawing '", drawing, "'", drawing_filename)
|
113 |
-
pipe = StableDiffusionPipeline.from_pretrained(this_model_addr, torch_dtype=
|
114 |
pipe.enable_attention_slicing()
|
115 |
pipe = pipe.to(device)
|
116 |
image = pipe(drawing).images[0]
|
@@ -140,10 +141,11 @@ def write_blog(inp, this_model, min_length, max_length, force_new):
|
|
140 |
return file.read()
|
141 |
print("generating blog '", blog_post_name, "'", target_filename)
|
142 |
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
|
143 |
-
|
144 |
-
#generator = pipeline('text-generation', model=
|
|
|
145 |
#generator = pipeline('text-generation', model=this_model_addr)
|
146 |
-
generator = pipeline('text-generation', model=this_model_addr, device=device, torch_dtype=
|
147 |
# AttributeError: 'TextGenerationPipeline' object has no attribute 'enable_attention_slicing'
|
148 |
#generator.enable_attention_slicing()
|
149 |
res = generator(blog_post_name, min_length=min_length, max_length=max_length, do_sample=True, temperature=0.7)
|
|
|
88 |
|
89 |
def draw(inp, this_model, force_new):
|
90 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
91 |
+
dtype = "torch.float16" if torch.cuda.is_available() else "torch.float32"
|
92 |
drawing = inp
|
93 |
if this_model == "stable-diffusion-2":
|
94 |
this_model_addr = "stabilityai/stable-diffusion-2"
|
|
|
111 |
print("found drawing ", drawing_filename)
|
112 |
return Image.open(drawing_filename)
|
113 |
print("generating drawing '", drawing, "'", drawing_filename)
|
114 |
+
pipe = StableDiffusionPipeline.from_pretrained(this_model_addr, torch_dtype=dtype)
|
115 |
pipe.enable_attention_slicing()
|
116 |
pipe = pipe.to(device)
|
117 |
image = pipe(drawing).images[0]
|
|
|
141 |
return file.read()
|
142 |
print("generating blog '", blog_post_name, "'", target_filename)
|
143 |
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
|
144 |
+
dtype = "torch.float16" if torch.cuda.is_available() else "torch.float32"
|
145 |
+
#generator = pipeline('text-generation', model='EleutherAI/gpt-neo-2.7B', device=device, torch_dtype=dtype)
|
146 |
+
#generator = pipeline('text-generation', model=this_model_addr, torch_dtype=dtype)
|
147 |
#generator = pipeline('text-generation', model=this_model_addr)
|
148 |
+
generator = pipeline('text-generation', model=this_model_addr, device=device, torch_dtype=dtype)
|
149 |
# AttributeError: 'TextGenerationPipeline' object has no attribute 'enable_attention_slicing'
|
150 |
#generator.enable_attention_slicing()
|
151 |
res = generator(blog_post_name, min_length=min_length, max_length=max_length, do_sample=True, temperature=0.7)
|