-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7d8cdc5
commit 8131846
Showing
8 changed files
with
112 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto | ||
*.md linguist-vendored=false | ||
*.md linguist-generated=false | ||
*.md linguist-documentation=false | ||
*.md linguist-detectable=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
psdenv/ | ||
output/ | ||
|
||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
++++++++++[>+>+++>+++++++>++++++++++<<<<-]>>>>-.++++++++++++++++++.---.+.--------------.-.<<+++++++++++++++.>>+.+++++++++.++++++.---------------.+++++++++++++.++.-------------------.++++++++.+++++.-.--------.+++++++++.++++++.<<+.>>-----------.+++++++++++.-----------------.+++++.<<.>>+.++++++. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import sys | ||
import os | ||
|
||
def main(): | ||
print("SDXL-Turbo Model Card") | ||
print("1. Text-to-image") | ||
print("2. Image-to-image") | ||
|
||
choice = input("Select an operation (1 or 2): ") | ||
|
||
if choice == "1": | ||
text_to_image_prompt() | ||
elif choice == "2": | ||
image_to_image_prompt() | ||
else: | ||
print("Invalid choice. Exiting.") | ||
sys.exit() | ||
|
||
def text_to_image_prompt(): | ||
print("Using SDXL-Turbo for Text-to-image:") | ||
print("Make sure to install the required packages using:") | ||
print("pip install diffusers transformers accelerate --upgrade") | ||
print() | ||
|
||
print("Sample prompt:") | ||
prompt = input("Enter a text prompt: ") | ||
|
||
text_to_image_code = f""" | ||
from diffusers import AutoPipelineForText2Image | ||
import torch | ||
from PIL import Image | ||
pipe = AutoPipelineForText2Image.from_pretrained("stabilityai/sdxl-turbo", torch_dtype=torch.float16, variant="fp16") | ||
pipe.to("cuda") | ||
prompt = "{prompt}" | ||
image = pipe(prompt=prompt, num_inference_steps=1, guidance_scale=0.0).images[0] | ||
image.save("output/output.jpg") | ||
""" | ||
|
||
print() | ||
print("Generated code snippet:") | ||
print(text_to_image_code) | ||
|
||
exec(text_to_image_code) | ||
|
||
def image_to_image_prompt(): | ||
print("Using SDXL-Turbo for Image-to-image:") | ||
print("Make sure to install the required packages using:") | ||
print("pip install diffusers transformers accelerate --upgrade") | ||
print() | ||
|
||
print("Sample prompt:") | ||
prompt = input("Enter a text prompt: ") | ||
|
||
image_to_image_code = f""" | ||
from diffusers import AutoPipelineForImage2Image | ||
from diffusers.utils import load_image | ||
import torch | ||
from PIL import Image | ||
pipe = AutoPipelineForImage2Image.from_pretrained("stabilityai/sdxl-turbo", torch_dtype=torch.float16, variant="fp16") | ||
pipe.to("cuda") | ||
init_image = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/cat.png").resize((512, 512)) | ||
prompt = "{prompt}" | ||
image = pipe(prompt, image=init_image, num_inference_steps=2, strength=0.5, guidance_scale=0.0).images[0] | ||
image.save("output/output.jpg") | ||
""" | ||
|
||
print() | ||
print("Generated code snippet:") | ||
print(image_to_image_code) | ||
|
||
exec(image_to_image_code) | ||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
transformers==4.37.1 | ||
pillow==10.2.0 | ||
|
||
pip install diffusers transformers accelerate --upgrade |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
@echo off | ||
|
||
set "VENV_DIR=psdenv" | ||
|
||
rem | ||
if not exist "%VENV_DIR%" ( | ||
rem | ||
python -m venv "%VENV_DIR%" | ||
) | ||
|
||
rem | ||
call "%VENV_DIR%\Scripts\activate" && python main.py | ||
|
||
rem | ||
pause |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
@echo off | ||
python -m venv psdenv | ||
cmd /k ".\psdenv\Scripts\activate & python main.py" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
python main.py |