Spaces:
Sleeping
Sleeping
Add image generation capabilities using Google DDPM
Browse files
app.py
CHANGED
|
@@ -3,6 +3,7 @@ from transformers import pipeline
|
|
| 3 |
import streamlit as st
|
| 4 |
from huggingface_hub import InferenceClient
|
| 5 |
import os
|
|
|
|
| 6 |
|
| 7 |
#Use an API endpoint to call in the MS inference client
|
| 8 |
apiToken = os.getenv("my_API_Key")
|
|
@@ -11,6 +12,9 @@ client = InferenceClient(api_key=apiToken)
|
|
| 11 |
#Instantiate the summarization pipeline - this will be used for the image generation
|
| 12 |
summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
|
| 13 |
|
|
|
|
|
|
|
|
|
|
| 14 |
#Input prompt
|
| 15 |
writingPrompt = st.text_input("Paste a writing prompt here: ")
|
| 16 |
|
|
@@ -35,4 +39,7 @@ if writingPrompt:
|
|
| 35 |
st.write(response_content)
|
| 36 |
|
| 37 |
summary = summarizer(response_content, max_length=130, min_length=30, do_sample=False)
|
| 38 |
-
st.write(summary[0]['summary_text']) # Displaying the summarized text in Streamlit
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
import streamlit as st
|
| 4 |
from huggingface_hub import InferenceClient
|
| 5 |
import os
|
| 6 |
+
from diffusers import DiffusionPipeline
|
| 7 |
|
| 8 |
#Use an API endpoint to call in the MS inference client
|
| 9 |
apiToken = os.getenv("my_API_Key")
|
|
|
|
| 12 |
#Instantiate the summarization pipeline - this will be used for the image generation
|
| 13 |
summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
|
| 14 |
|
| 15 |
+
#Instantiate the image genereation pipeline
|
| 16 |
+
imagePipeline = DiffusionPipeline.from_pretrained("google/ddpm-cifar10-32")
|
| 17 |
+
|
| 18 |
#Input prompt
|
| 19 |
writingPrompt = st.text_input("Paste a writing prompt here: ")
|
| 20 |
|
|
|
|
| 39 |
st.write(response_content)
|
| 40 |
|
| 41 |
summary = summarizer(response_content, max_length=130, min_length=30, do_sample=False)
|
| 42 |
+
st.write(summary[0]['summary_text']) # Displaying the summarized text in Streamlit
|
| 43 |
+
|
| 44 |
+
image = pipe(summary).images[0]
|
| 45 |
+
st.image(image)
|