Skip to content

Instantly share code, notes, and snippets.

View garystafford's full-sized avatar
💭
Happily Coding!

Gary A. Stafford garystafford

💭
Happily Coding!
View GitHub Profile
View print_pytorch_gpu_versions.py
import torch
print(torch.__version__) # e.g., 2.0.0 (at the time of the post)
print(torch.cuda.get_device_name(0)) # e.g., NVIDIA A10G
View finetuning_sdxl_test.py
pipeline = DiffusionPipeline.from_pretrained(
model_name_base,
torch_dtype=torch.float16,
).to(device)
# new LoRA weights from fine-tuning process
pipeline.load_lora_weights(
project_name,
weight_name="pytorch_lora_weights.safetensors"
)
View fine_tuned_photorealistic_night.py
subject_prompt = """oue, photo of a oue electric scooter in a brightly colored
neon-lite city at night, sleek design, smooth curves, colorful, nighttime,
urban environment, futuristic cityscape"""
subject_negative_prompt = """person, people, human, rider, floating objects, daytime,
sunlight, text, words, writing, letters, phrases, trademark, watermark, icon, logo,
banner, signature, username, monochrome, cropped, cut-off, patterned background"""
refiner_prompt = """ultra-high-definition, photorealistic, 8k uhd, high-quality,
ultra sharp detail"""
View fine_tuned_photorealistic_daytime.py
subject_prompt = """oue, photo of a oue electric scooter, sleek, smooth curves, colorful,
daytime, urban, futuristic cityscape"""
subject_negative_prompt = """person, people, human, rider, floating objects, text,
words, writing, letters, phrases, trademark, watermark, icon, logo, banner, signature,
username, monochrome, cropped, cut-off, patterned background"""
refiner_prompt = """ultra-high-definition, photorealistic, 8k uhd, high-quality,
ultra sharp detail"""
View fine_tuned_bw_marker_renderings.py
pipeline = DiffusionPipeline.from_pretrained(
model_name_base,
torch_dtype=torch.float16,
).to(device)
pipeline.load_lora_weights(
project_name,
weight_name="pytorch_lora_weights.safetensors"
)
View autotrain_dreambooth_command.py
!autotrain dreambooth \
--model ${MODEL_NAME} \
--project-name ${PROJECT_NAME} \
--image-path "${IMAGE_PATH}" \
--prompt "${INSTANCE_PROMPT}" \
--class-prompt "${CLASS_PROMPT}" \
--resolution ${RESOLUTION} \
--batch-size ${BATCH_SIZE} \
--num-steps ${NUM_STEPS} \
--gradient-accumulation ${GRADIENT_ACCUMULATION} \
View autotrain_dreambooth_params.py
import os
# project configuration
project_name = "mb_amg_gt_oue_dreambooth"
model_name_base = "stabilityai/stable-diffusion-xl-base-1.0"
model_name_refiner = "stabilityai/stable-diffusion-xl-refiner-1.0"
# fine-tuning prompts
# 'oue' is a rare tokens, 'car' is a class
instance_prompt = "photo of oue car"
View sdxl_studio_demo_imports.py
%%sh
export PIP_ROOT_USER_ACTION=ignore
pip install -Uq pip # optional
pip install -Uq autotrain-advanced
pip install -q ipywidgets==7.8.1
View untuned_photorealistic_images_square.py
from diffusers import DiffusionPipeline, StableDiffusionXLImg2ImgPipeline
device = "cuda" # cpu or cuda
pipeline = DiffusionPipeline.from_pretrained(
model_name_base,
torch_dtype=torch.float16,
).to(device)
refiner = StableDiffusionXLImg2ImgPipeline.from_pretrained(
View fine_tuned_marker_renderings_wide.py
# optional descriptive terms: sleek, futuristic, metallic, colorful, urban
subject_prompt = """oue, marker rendering of oue electric scooter, concept art,
futuristic cityscape, solid color background, bright vibrant colors, marker, sketch,
illustration, illustrative, marker drawing, expressive strokes, graphic"""
subject_negative_prompt = """person, people, human, rider, floating objects, text,
words, writing, letters, phrases, trademark, watermark, icon, logo, banner, signature,
username, monochrome, cropped, cut-off, patterned background"""
refiner_prompt = """sharp, crisp, in-focus, uncropped, high-quality"""