Witcape commited on
Commit
d79505b
·
verified ·
1 Parent(s): ccf17b0

Upload new_finetune.py

Browse files
Files changed (1) hide show
  1. new_finetune.py +46 -0
new_finetune.py ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ """New_Finetune.ipynb
3
+
4
+ Automatically generated by Colaboratory.
5
+
6
+ Original file is located at
7
+ https://colab.research.google.com/drive/1HBmhGB58E7LDJPmp4fGI-mJhRb5OZDWo
8
+ """
9
+
10
+ !pip install huggingface_hub
11
+ from huggingface_hub import notebook_login
12
+ notebook_login()
13
+
14
+ !pip install --upgrade diffusers[torch]
15
+
16
+ from torch import autocast
17
+ from diffusers import StableDiffusionPipeline
18
+
19
+ pipe = StableDiffusionPipeline.from_pretrained(
20
+ "CompVis/stable-diffusion-v1-4",
21
+ use_auth_token=True
22
+ ).to("cuda")
23
+
24
+ prompt = "a sleek logo of a company, named 'SPARK', emblem style, our moto is 'Sparking some code to win', abstract logo, professinal, centre align, black background, the logo should resemble the name, clean"
25
+ with autocast("cuda"):
26
+ output = pipe(prompt)
27
+ print(output.keys())
28
+
29
+ import matplotlib.pyplot as plt
30
+ import numpy as np
31
+ image_data = output["images"]
32
+
33
+ # If the image data is a list, assume it contains PIL images
34
+ if isinstance(image_data, list):
35
+ for i, image in enumerate(image_data):
36
+ # Convert PIL image to numpy array
37
+ image_np = np.array(image)
38
+
39
+ # Display the image using Matplotlib
40
+ plt.imshow(image_np)
41
+ plt.axis('off')
42
+ plt.title(f"Image {i+1}")
43
+ plt.show()
44
+ else:
45
+ print("Unexpected image format. Unable to display.")
46
+