File size: 1,342 Bytes
d79505b
 
 
 
 
 
 
 
 
a029ebf
2195609
d79505b
 
 
2195609
d79505b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# -*- coding: utf-8 -*-
"""New_Finetune.ipynb

Automatically generated by Colaboratory.

Original file is located at
    https://colab.research.google.com/drive/1HBmhGB58E7LDJPmp4fGI-mJhRb5OZDWo
"""

streamlit run app.py
!pip install huggingface_hub
from huggingface_hub import notebook_login
notebook_login()

!pip install --upgrade diffusers[torch]

from torch import autocast
from diffusers import StableDiffusionPipeline

pipe = StableDiffusionPipeline.from_pretrained(
    "CompVis/stable-diffusion-v1-4",
    use_auth_token=True
).to("cuda")

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"
with autocast("cuda"):
    output = pipe(prompt)
print(output.keys())

import matplotlib.pyplot as plt
import numpy as np
image_data = output["images"]

# If the image data is a list, assume it contains PIL images
if isinstance(image_data, list):
    for i, image in enumerate(image_data):
        # Convert PIL image to numpy array
        image_np = np.array(image)

        # Display the image using Matplotlib
        plt.imshow(image_np)
        plt.axis('off')
        plt.title(f"Image {i+1}")
        plt.show()
else:
    print("Unexpected image format. Unable to display.")