morj commited on
Commit
58c874e
·
verified ·
1 Parent(s): 6237efb

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +42 -1
README.md CHANGED
@@ -13,6 +13,7 @@ tags:
13
  - '#keras'
14
  - '#tensorflow'
15
  - '#diffusers'
 
16
  ---
17
 
18
  # Model Card for Model ID
@@ -34,4 +35,44 @@ This model uses the KerasCV implementation of stability.ai's text-to-image model
34
  - **Model type:** Diffusion-based text-to-image generative model
35
  - **Language(s) (NLP):** Python
36
  - **License:** CreativeML Open RAIL++-M License
37
- - **Finetuned from model [https://huggingface.co/CompVis/stable-diffusion-v1-4]:** https://github.com/keras-team/keras-cv/tree/master/keras_cv/models/stable_diffusion
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  - '#keras'
14
  - '#tensorflow'
15
  - '#diffusers'
16
+ base_model: CompVis/stable-diffusion-v1-4
17
  ---
18
 
19
  # Model Card for Model ID
 
35
  - **Model type:** Diffusion-based text-to-image generative model
36
  - **Language(s) (NLP):** Python
37
  - **License:** CreativeML Open RAIL++-M License
38
+ - **Finetuned from model [https://huggingface.co/CompVis/stable-diffusion-v1-4]:** https://github.com/keras-team/keras-cv/tree/master/keras_cv/models/stable_diffusion
39
+
40
+
41
+ ## To Generate your own Examples:
42
+ Install Dependencies
43
+ !pip install keras-cv==0.6.0 -q
44
+ !pip install -U tensorflow -q
45
+ !pip install keras-core -q
46
+ Imports
47
+ from textwrap import wrap
48
+ import os
49
+ import keras_cv
50
+ import matplotlib.pyplot as plt
51
+ import numpy as np
52
+ import pandas as pd
53
+ import tensorflow as tf
54
+ import tensorflow.experimental.numpy as tnp
55
+ from keras_cv.models.stable_diffusion.clip_tokenizer import SimpleTokenizer
56
+ from keras_cv.models.stable_diffusion.diffusion_model import DiffusionModel
57
+ from keras_cv.models.stable_diffusion.image_encoder import ImageEncoder
58
+ from keras_cv.models.stable_diffusion.noise_scheduler import NoiseScheduler
59
+ from keras_cv.models.stable_diffusion.text_encoder import TextEncoder
60
+ from tensorflow import keras
61
+ Create a base Stable diffusion Model
62
+ my_base_model = keras_cv.models.StableDiffusion(img_width=512, img_height=512)
63
+ Load Weights from our h5 model which is hosted on Hugging Face here:
64
+ my_base_model.diffusion_model.load_weights('/path/to/file/renaissance_model.h5')
65
+ Create a variable to hold the values of the to-be-generated image such as prompt, batch size, iterations, and seed
66
+ img = my_base_model.text_to_image(
67
+ prompt="A woman with an enigmatic smile against a dark background",
68
+ batch_size=1, # How many images to generate at once
69
+ num_steps=25, # Number of iterations (controls image quality)
70
+ seed=123, # Set this to always get the same image from the same prompt
71
+ )
72
+ Display using the function:
73
+ def plot_images(images):
74
+ plt.figure(figsize=(5, 5))
75
+ plt.imshow(images)
76
+ plt.axis("off")
77
+
78
+ plot_images(img)