spaces
Browse files- baseline_utils.py +3 -1
- requirements.txt +2 -1
baseline_utils.py
CHANGED
@@ -6,6 +6,7 @@ import google.generativeai as genai
|
|
6 |
from diffusers import AutoPipelineForText2Image
|
7 |
import torch
|
8 |
import os
|
|
|
9 |
|
10 |
# Utilize the Google Cloud Vision API to recognize text in the
|
11 |
# input input_images (diary input_images), https://cloud.google.com/vision.
|
@@ -74,6 +75,7 @@ def analyze_writer_image(image_path, api_key):
|
|
74 |
# input_images https://huggingface.co/stabilityai/sdxl-turbo.
|
75 |
# You can try to output several input_images for a diary entry. Analyze how accurate the results,
|
76 |
# and think about what could be improved.
|
|
|
77 |
def generate_comic_book(diary_text, writer_description, num_pages=4):
|
78 |
pipe = AutoPipelineForText2Image.from_pretrained(
|
79 |
"stabilityai/sdxl-turbo",
|
@@ -94,7 +96,7 @@ def generate_comic_book(diary_text, writer_description, num_pages=4):
|
|
94 |
# print("CUDA and MPS not available. Falling back to CPU.")
|
95 |
|
96 |
# Move the model to the selected device
|
97 |
-
pipe
|
98 |
|
99 |
# Create a directory to store the comic book input_images
|
100 |
os.makedirs("comic_book", exist_ok=True)
|
|
|
6 |
from diffusers import AutoPipelineForText2Image
|
7 |
import torch
|
8 |
import os
|
9 |
+
import spaces
|
10 |
|
11 |
# Utilize the Google Cloud Vision API to recognize text in the
|
12 |
# input input_images (diary input_images), https://cloud.google.com/vision.
|
|
|
75 |
# input_images https://huggingface.co/stabilityai/sdxl-turbo.
|
76 |
# You can try to output several input_images for a diary entry. Analyze how accurate the results,
|
77 |
# and think about what could be improved.
|
78 |
+
@spaces.GPU
|
79 |
def generate_comic_book(diary_text, writer_description, num_pages=4):
|
80 |
pipe = AutoPipelineForText2Image.from_pretrained(
|
81 |
"stabilityai/sdxl-turbo",
|
|
|
96 |
# print("CUDA and MPS not available. Falling back to CPU.")
|
97 |
|
98 |
# Move the model to the selected device
|
99 |
+
pipe.to('cuda')
|
100 |
|
101 |
# Create a directory to store the comic book input_images
|
102 |
os.makedirs("comic_book", exist_ok=True)
|
requirements.txt
CHANGED
@@ -6,4 +6,5 @@ diffusers
|
|
6 |
torch
|
7 |
gradio
|
8 |
transformers
|
9 |
-
accelerate
|
|
|
|
6 |
torch
|
7 |
gradio
|
8 |
transformers
|
9 |
+
accelerate
|
10 |
+
spaces
|