From 27e784c4dc1cf1eb157b5c0230205b6a533db3c7 Mon Sep 17 00:00:00 2001 From: Simon Dai Date: Wed, 6 Nov 2024 08:05:03 -0800 Subject: [PATCH] add test case scripts --- scripts/download_flux.ps1 | 54 +++++++++++++++++++++++++++++++++++ scripts/scripts.sh | 20 +++++++++++++ scripts/test_cases.ps1 | 43 ++++++++++++++++++++++++++++ scripts/test_cases_2.ps1 | 43 ++++++++++++++++++++++++++++ scripts/test_cases_3_flux.ps1 | 39 +++++++++++++++++++++++++ scripts/test_cases_4_flux.ps1 | 41 ++++++++++++++++++++++++++ 6 files changed, 240 insertions(+) create mode 100644 scripts/download_flux.ps1 create mode 100644 scripts/scripts.sh create mode 100644 scripts/test_cases.ps1 create mode 100644 scripts/test_cases_2.ps1 create mode 100644 scripts/test_cases_3_flux.ps1 create mode 100644 scripts/test_cases_4_flux.ps1 diff --git a/scripts/download_flux.ps1 b/scripts/download_flux.ps1 new file mode 100644 index 000000000..314bf4e15 --- /dev/null +++ b/scripts/download_flux.ps1 @@ -0,0 +1,54 @@ +# PowerShell script to download models from Hugging Face + +# Function to check if huggingface-cli is installed +function Test-HuggingFaceCLI { + try { + huggingface-cli --version | Out-Null + return $true + } catch { + return $false + } +} + +# URLs for downloading models +$models = @{ + "flux1-dev" = "https://huggingface.co/black-forest-labs/FLUX.1-dev/blob/main/flux1-dev.safetensors" + "flux1-schnell" = "https://huggingface.co/black-forest-labs/FLUX.1-schnell/blob/main/flux1-schnell.safetensors" + "vae" = "https://huggingface.co/black-forest-labs/FLUX.1-dev/blob/main/ae.safetensors" + "clip_l" = "https://huggingface.co/comfyanonymous/flux_text_encoders/blob/main/clip_l.safetensors" + "t5xxl_fp16" = "https://huggingface.co/comfyanonymous/flux_text_encoders/blob/main/t5xxl_fp16.safetensors" +} + +# Output folder +$outputDir = "../models" +New-Item -ItemType Directory -Force -Path $outputDir | Out-Null + +# Use huggingface-cli if available, otherwise use Invoke-WebRequest +if (Test-HuggingFaceCLI) { + Write-Output "Using huggingface-cli for downloads..." + + # Authenticate with Hugging Face if required + # huggingface-cli login + + # Download each model using huggingface-cli + foreach ($modelName in $models.Keys) { + $repo_id = $models[$modelName] -replace "https://huggingface.co/(.+?)/blob/main/.+", '$1' + $fileName = $models[$modelName] -replace ".+/blob/main/", "" + + Write-Output "Downloading $modelName..." + huggingface-cli download $repo_id $fileName --cache-dir $outputDir + } +} else { + Write-Output "huggingface-cli not found. Using direct URLs for downloads..." + + # Download each model using direct URLs + foreach ($modelName in $models.Keys) { + $url = $models[$modelName] + $outputPath = Join-Path $outputDir ($url -replace ".+/blob/main/", "") + + Write-Output "Downloading $modelName from $url..." + Invoke-WebRequest -Uri $url -OutFile $outputPath + } +} + +Write-Output "Downloads complete. Files saved in $outputDir." diff --git a/scripts/scripts.sh b/scripts/scripts.sh new file mode 100644 index 000000000..bdd4f963b --- /dev/null +++ b/scripts/scripts.sh @@ -0,0 +1,20 @@ + .\build\bin\Release\sd.exe -m C:\Users\dsx19\.cache\huggingface\hub\models--stabilityai--stable-diffusion-3-medium\blobs\69a950c5d143ce782a7423c532c8a12b75da6a37b0e6f26a322acf4e76208912 --cfg-scale 5 --steps 30 --sampling-method euler -H 1024 -W 1024 --seed 42 -p "fantasy medieval village world inside a glass sphere , high detail, fantasy, realistic, light effect, hyper detail, volumetric lighting, cinematic, macro, depth of field, blur, red light and clouds from the back, highly detailed epic cinematic concept art cg render made in maya, blender and photoshop, octane render, excellent composition, dynamic dramatic cinematic lighting, aesthetic, very inspirational, world inside a glass sphere by james gurney by artgerm with james jean, joe fenton and tristan eaton by ross tran, fine details, 4k resolution" + + +.\build\bin\Release\sd.exe -m C:\Users\dsx19\.cache\huggingface\hub\models--stabilityai--stable-diffusion-3-medium\blobs\69a950c5d143ce782a7423c532c8a12b75da6a37b0e6f26a322acf4e76208912 --cfg-scale 5 --steps 30 --sampling-method euler -H 1024 -W 1024 --seed 42 -p "Dreamlike floating islands suspended in an infinite galaxy, each island covered in lush gardens and flowing waterfalls, surrounded by enormous ethereal butterflies radiating neon blues and pinks, cosmic dust swirling gently around. The scene is illuminated by a mix of starlight and the soft glow from the butterflies’ wings, creating an enchanting fantasy world." + +.\build\bin\Release\sd.exe -m C:\Users\dsx19\.cache\huggingface\hub\models--stabilityai--stable-diffusion-3-medium\blobs\69a950c5d143ce782a7423c532c8a12b75da6a37b0e6f26a322acf4e76208912 --cfg-scale 5 --steps 30 --sampling-method euler -H 1024 -W 1024 --seed 42 -p "A vibrant, timeless carnival set on fluffy, sunlit clouds above an endless ocean. Brightly colored tents, Ferris wheels, and carousel animals float as if weightless, with wisps of cloud mingling through each ride, illuminated by a mix of carnival lights casting warm glows." + +.\build\bin\Release\sd.exe -m C:\Users\dsx19\.cache\huggingface\hub\models--stabilityai--stable-diffusion-3-medium\blobs\69a950c5d143ce782a7423c532c8a12b75da6a37b0e6f26a322acf4e76208912 --cfg-scale 5 --steps 30 --sampling-method euler -H 1024 -W 1024 --seed 42 -p "A futuristic, overgrown garden where flowers emit neon lights in shades of violet and aqua, blooming from trees made of metal and wires. Robotic butterflies flit between the plants, and in the background, abandoned skyscrapers slowly crumble into the landscape." + +.\build\bin\Release\sd.exe -m C:\Users\dsx19\.cache\huggingface\hub\models--stabilityai--stable-diffusion-3-medium\blobs\69a950c5d143ce782a7423c532c8a12b75da6a37b0e6f26a322acf4e76208912 --cfg-scale 5 --steps 30 --sampling-method euler -H 1024 -W 1024 --seed 42 -p "Ancient stone temple ruins overtaken by gigantic, bioluminescent mushrooms glowing in rich greens and purples, casting an otherworldly light on the moss-covered stones, with ethereal fog swirling around the roots." + +.\build\bin\Release\sd.exe -m C:\Users\dsx19\.cache\huggingface\hub\models--stabilityai--stable-diffusion-3-medium\blobs\69a950c5d143ce782a7423c532c8a12b75da6a37b0e6f26a322acf4e76208912 --cfg-scale 5 --steps 30 --sampling-method euler -H 1024 -W 1024 --seed 42 -p "A forest existing across dimensions, where trees have shimmering, translucent bark, and from their roots grow crystals of varying colors and intensities. Strange, ethereal creatures dart between trees, and the sky above shimmers in shifting hues." + +.\build\bin\Release\sd.exe -m C:\Users\dsx19\.cache\huggingface\hub\models--stabilityai--stable-diffusion-3-medium\blobs\69a950c5d143ce782a7423c532c8a12b75da6a37b0e6f26a322acf4e76208912 --cfg-scale 5 --steps 30 --sampling-method euler -H 1024 -W 1024 --seed 42 -p "A bustling, medieval-style city built on the scales of a colossal dragon sleeping in a vast valley, with stone bridges arching across its wings, and soft sunlight pouring through mountain peaks in the background." + + + +"Dreamlike floating islands suspended in an infinite galaxy, each island covered in lush gardens and flowing waterfalls, surrounded by enormous ethereal butterflies radiating neon blues and pinks, cosmic dust swirling gently around. The scene is illuminated by a mix of starlight and the soft glow from the butterflies’ wings, creating an enchanting fantasy world, hyper-detailed, volumetric light, surreal, with an otherworldly calm, 4k resolution." + +"A vibrant, timeless carnival set on fluffy, sunlit clouds above an endless ocean. Brightly colored tents, Ferris wheels, and carousel animals float as if weightless, with wisps of cloud mingling through each ride. Carnival lights cast warm glows over the cloudy landscape, and children’s laughter seems to echo from unseen spaces. Light beams and lens flares create a nostalgic, magical ambiance, with tiny, whimsical details in every corner, 4k resolution, hyper-detailed, cinematic depth." \ No newline at end of file diff --git a/scripts/test_cases.ps1 b/scripts/test_cases.ps1 new file mode 100644 index 000000000..5bad4a395 --- /dev/null +++ b/scripts/test_cases.ps1 @@ -0,0 +1,43 @@ +# PowerShell script to generate images using sd.exe with multiple prompts + +# Path to the sd.exe executable +$sdPath = ".\build\bin\Release\sd.exe" + +# Model path +$modelPath = "C:\Users\dsx19\.cache\huggingface\hub\models--stabilityai--stable-diffusion-3-medium\blobs\69a950c5d143ce782a7423c532c8a12b75da6a37b0e6f26a322acf4e76208912" + +# Output directory +$outputDir = ".\output" +New-Item -ItemType Directory -Force -Path $outputDir | Out-Null + +# Array of prompts +$prompts = @( + "Dreamlike floating islands suspended in an infinite galaxy, each island covered in lush gardens and flowing waterfalls, surrounded by enormous ethereal butterflies radiating neon blues and pinks, cosmic dust swirling gently around.", + "A vibrant, timeless carnival set on fluffy, sunlit clouds above an endless ocean. Brightly colored tents, Ferris wheels, and carousel animals float as if weightless, with wisps of cloud mingling through each ride.", + "A futuristic, overgrown garden where flowers emit neon lights in shades of violet and aqua, blooming from trees made of metal and wires. Robotic butterflies flit between the plants.", + "Ancient stone temple ruins overtaken by gigantic, bioluminescent mushrooms glowing in rich greens and purples, casting an otherworldly light on the moss-covered stones.", + "A forest existing across dimensions, where trees have shimmering, translucent bark, and from their roots grow crystals of varying colors and intensities.", + "A bustling, medieval-style city built on the scales of a colossal dragon sleeping in a vast valley, with stone bridges arching across its wings.", + "A boundless desert stretching under a golden sunset, scattered with colossal, broken statues of forgotten gods and mythic creatures, half-buried in the sand.", + "An infinite library without shelves, where books and pages float in mid-air, surrounded by flickering candle flames that hover, casting warm amber light across ink-stained parchment.", + "A tranquil scene of a moonlit ocean dotted with floating lanterns, their warm light illuminating celestial jellyfish drifting gently among the waves.", + "A clockwork-inspired planet with miniature rotating continents and rivers flowing through gears, encapsulated in a glass sphere." +) + +# Loop through each prompt and execute the command +for ($i = 0; $i -lt $prompts.Count; $i++) { + $prompt = $prompts[$i] + $outputFileName = "output_image_$($i + 1).png" # Unique filename for each output image + $outputFilePath = Join-Path $outputDir $outputFileName + + # Command to execute + $command = "& $sdPath -m $modelPath --cfg-scale 5 --steps 30 --sampling-method euler -H 1024 -W 1024 --seed 42 -p `"$prompt`" -o `"$outputFilePath`"" + + # Execute the command + Invoke-Expression $command + + # Output the name of the generated file + Write-Output "Generated image saved as: $outputFileName" +} + +Write-Output "All images have been generated and saved in $outputDir." diff --git a/scripts/test_cases_2.ps1 b/scripts/test_cases_2.ps1 new file mode 100644 index 000000000..97c71dfe2 --- /dev/null +++ b/scripts/test_cases_2.ps1 @@ -0,0 +1,43 @@ +# PowerShell script to generate images using sd.exe with various styles + +# Path to the sd.exe executable +$sdPath = ".\build\bin\Release\sd.exe" + +# Model path +$modelPath = "C:\Users\dsx19\.cache\huggingface\hub\models--stabilityai--stable-diffusion-3-medium\blobs\69a950c5d143ce782a7423c532c8a12b75da6a37b0e6f26a322acf4e76208912" + +# Output directory +$outputDir = ".\output" +New-Item -ItemType Directory -Force -Path $outputDir | Out-Null + +# Array of prompts with different styles +$prompts = @( + "A cartoon-style whimsical village with colorful houses, smiling animals, and cheerful villagers, bright sunny day, playful and vibrant colors, cartoon aesthetics.", + "A photorealistic depiction of a serene mountain landscape at sunrise, with misty valleys and vibrant flowers, capturing the essence of tranquility and natural beauty.", + "A cyberpunk cityscape at night, filled with neon lights, futuristic skyscrapers, and bustling streets, highly detailed, with an atmosphere of mystery and excitement.", + "A vintage sepia-toned photograph of a classic car parked under a blooming cherry blossom tree, evoking nostalgia and warmth.", + "An abstract art piece featuring swirling colors and geometric shapes, creating a sense of movement and energy, vibrant and expressive.", + "A minimalistic Japanese zen garden with raked sand patterns, carefully placed rocks, and a tranquil koi pond, capturing simplicity and harmony.", + "A fantasy portrait of a knight in shining armor standing in a lush forest, with sunlight filtering through the trees, heroic and majestic, detailed textures.", + "A retro comic book cover featuring superheroes battling villains, bold colors, dynamic poses, and dramatic speech bubbles, capturing the excitement of classic comics.", + "A hyper-detailed illustration of a bustling marketplace in an ancient civilization, with merchants, exotic goods, and lively interactions, rich in culture and history.", + "A surreal landscape of floating islands connected by rainbows, with whimsical creatures and an enchanting sky, combining elements of fantasy and dreamlike quality." +) + +# Loop through each prompt and execute the command +for ($i = 0; $i -lt $prompts.Count; $i++) { + $prompt = $prompts[$i] + $outputFileName = "output_image_$($i + 1).png" # Unique filename for each output image + $outputFilePath = Join-Path $outputDir $outputFileName + + # Command to execute + $command = "& $sdPath -m $modelPath --cfg-scale 5 --steps 30 --sampling-method euler -H 1024 -W 1024 --seed 42 -p `"$prompt`" -o `"$outputFilePath`"" + + # Execute the command + Invoke-Expression $command + + # Output the name of the generated file + Write-Output "Generated image saved as: $outputFileName" +} + +Write-Output "All images have been generated and saved in $outputDir." diff --git a/scripts/test_cases_3_flux.ps1 b/scripts/test_cases_3_flux.ps1 new file mode 100644 index 000000000..f4951f3d4 --- /dev/null +++ b/scripts/test_cases_3_flux.ps1 @@ -0,0 +1,39 @@ +# PowerShell script to generate images using sd.exe with FLUX models + +# Path to the sd.exe executable +$sdPath = "..\build\bin\Release\sd.exe" + +# Model paths for the FLUX models +$modelPath = "C:\Users\dsx19\Documents\GIT\stable-diffusion.cpp\models\models--black-forest-labs--FLUX.1-schnell\flux1-schnell-q8_0.gguf" +$vaePath = "C:\Users\dsx19\Documents\GIT\stable-diffusion.cpp\models\models--black-forest-labs--FLUX.1-dev\blobs\afc8e28272cd15db3919bacdb6918ce9c1ed22e96cb12c4d5ed0fba823529e38" + +# Output directory +$outputDir = ".\output" +New-Item -ItemType Directory -Force -Path $outputDir | Out-Null + +# Array of prompts with different styles +$prompts = @( + "A cartoon-style whimsical village with colorful houses, smiling animals, and cheerful villagers, bright sunny day, playful and vibrant colors, cartoon aesthetics.", + "A photorealistic depiction of a serene mountain landscape at sunrise, with misty valleys and vibrant flowers, capturing the essence of tranquility and natural beauty.", + "A cyberpunk cityscape at night, filled with neon lights, futuristic skyscrapers, and bustling streets, highly detailed, with an atmosphere of mystery and excitement.", + "A vintage sepia-toned photograph of a classic car parked under a blooming cherry blossom tree, evoking nostalgia and warmth.", + "An abstract art piece featuring swirling colors and geometric shapes, creating a sense of movement and energy, vibrant and expressive." +) + +# Loop through each prompt and execute the command +for ($i = 0; $i -lt $prompts.Count; $i++) { + $prompt = $prompts[$i] + $outputFileName = "flux_output_image_$($i + 1).png" # Unique filename for each output image + $outputFilePath = Join-Path $outputDir $outputFileName + + # Command to execute + $command = "& $sdPath --diffusion-model $modelPath --vae $vaePath --cfg-scale 1 --steps 30 --sampling-method euler -H 1024 -W 1024 --seed 42 -p `"$prompt`" -o `"$outputFilePath`"" + + # Execute the command + Invoke-Expression $command + + # Output the name of the generated file + Write-Output "Generated image saved as: $outputFileName" +} + +Write-Output "All images have been generated and saved in $outputDir." diff --git a/scripts/test_cases_4_flux.ps1 b/scripts/test_cases_4_flux.ps1 new file mode 100644 index 000000000..1bc56dd18 --- /dev/null +++ b/scripts/test_cases_4_flux.ps1 @@ -0,0 +1,41 @@ +# PowerShell script to generate images using sd.exe with FLUX models and CLIP model + +# Path to the sd.exe executable +$sdPath = "..\build\bin\Release\sd.exe" + +# Model paths for the FLUX models +$modelPath = "C:\Users\dsx19\Documents\GIT\stable-diffusion.cpp\models\models--black-forest-labs--FLUX.1-schnell\flux1-schnell-q8_0.gguf" +$vaePath = "C:\Users\dsx19\Documents\GIT\stable-diffusion.cpp\models\models--black-forest-labs--FLUX.1-dev\blobs\afc8e28272cd15db3919bacdb6918ce9c1ed22e96cb12c4d5ed0fba823529e38" +$clipModelPath = "C:\Users\dsx19\Documents\GIT\stable-diffusion.cpp\models\models--comfyanonymous--flux_text_encoders\blobs\660c6f5b1abae9dc498ac2d21e1347d2abdb0cf6c0c0c8576cd796491d9a6cdd" +$t5 = "C:\Users\dsx19\Documents\GIT\stable-diffusion.cpp\models\models--comfyanonymous--flux_text_encoders\blobs\6e480b09fae049a72d2a8c5fbccb8d3e92febeb233bbe9dfe7256958a9167635" + +# Output directory +$outputDir = ".\output" +New-Item -ItemType Directory -Force -Path $outputDir | Out-Null + +# Array of prompts with different styles +$prompts = @( + "A cartoon-style whimsical village with colorful houses, smiling animals, and cheerful villagers, bright sunny day, playful and vibrant colors, cartoon aesthetics.", + "A photorealistic depiction of a serene mountain landscape at sunrise, with misty valleys and vibrant flowers, capturing the essence of tranquility and natural beauty.", + "A cyberpunk cityscape at night, filled with neon lights, futuristic skyscrapers, and bustling streets, highly detailed, with an atmosphere of mystery and excitement.", + "A vintage sepia-toned photograph of a classic car parked under a blooming cherry blossom tree, evoking nostalgia and warmth.", + "An abstract art piece featuring swirling colors and geometric shapes, creating a sense of movement and energy, vibrant and expressive." +) + +# Loop through each prompt and execute the command +for ($i = 0; $i -lt $prompts.Count; $i++) { + $prompt = $prompts[$i] + $outputFileName = "flux_output_image_$($i + 1).png" # Unique filename for each output image + $outputFilePath = Join-Path $outputDir $outputFileName + + # Command to execute + $command = "& $sdPath --diffusion-model $modelPath --vae $vaePath --clip_l $clipModelPath --t5xxl $t5 --cfg-scale 1 --steps 30 --sampling-method euler -H 1024 -W 1024 --seed 42 -p `"$prompt`" -o `"$outputFilePath`"" + + # Execute the command + Invoke-Expression $command + + # Output the name of the generated file + Write-Output "Generated image saved as: $outputFileName" +} + +Write-Output "All images have been generated and saved in $outputDir."