Skip to content

Commit

Permalink
print to stdout for test visibility (huggingface#937)
Browse files Browse the repository at this point in the history
Co-authored-by: dan <dan@nod-labs.com>
  • Loading branch information
dan-garvey and dan-garvey authored Feb 6, 2023
1 parent ffa17f6 commit 157ae64
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 21 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test-models.yml
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,5 @@ jobs:
if: matrix.suite == 'vulkan' && matrix.os == '7950x'
run: |
./setup_venv.ps1
./shark.venv/Scripts/activate
python build_tools/stable_diffusion_testing.py --device=vulkan
2 changes: 1 addition & 1 deletion build_tools/image_comparison.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def compare_images(new_filename, golden_filename):
golden = np.array(Image.open(golden_filename)) / 255.0
diff = np.abs(new - golden)
mean = np.mean(diff)
if mean > 0.01:
if mean > 0.1:
subprocess.run(
["gsutil", "cp", new_filename, "gs://shark_tank/testdata/builder/"]
)
Expand Down
7 changes: 0 additions & 7 deletions build_tools/stable_diff_main_test.sh

This file was deleted.

27 changes: 14 additions & 13 deletions build_tools/stable_diffusion_testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ def test_loop(device="vulkan", beta=False, extra_flags=[]):
os.mkdir("./test_images")
os.mkdir("./test_images/golden")
hf_model_names = model_config_dicts[0].values()
tuned_options = ["--no-use_tuned"] #'use_tuned']
devices = ["vulkan"]
tuned_options = ["--no-use_tuned", "use_tuned"]
if beta:
extra_flags.append("--beta_models=True")
for model_name in hf_model_names:
Expand All @@ -33,34 +32,36 @@ def test_loop(device="vulkan", beta=False, extra_flags=[]):
"python",
"apps/stable_diffusion/scripts/txt2img.py",
"--device=" + device,
"--output_dir=./test_images/" + model_name,
"--prompt=cyberpunk forest by Salvador Dali",
"--output_dir="
+ os.path.join(os.getcwd(), "test_images", model_name),
"--hf_model_id=" + model_name,
use_tune,
]
command += extra_flags
generated_image = not subprocess.call(
command, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL
command, stdout=subprocess.DEVNULL
)
if generated_image:
print(" ".join(command))
print("Successfully generated image")
os.makedirs(
"./test_images/golden/" + model_name, exist_ok=True
)
download_public_file(
"gs://shark_tank/testdata/golden/" + model_name,
"./test_images/golden/" + model_name,
)
comparison = [
"python",
"build_tools/image_comparison.py",
"--golden_url=gs://shark_tank/testdata/golden/"
+ model_name
+ "/*.png",
"--newfile=./test_images/" + model_name + "/*.png",
]
test_file = glob("./test_images/" + model_name + "/*.png")[0]
test_file_path = os.path.join(
os.getcwd(), "test_images", model_name, "generated_imgs"
)
test_file = glob(test_file_path + "/*.png")[0]
golden_path = "./test_images/golden/" + model_name + "/*.png"
golden_file = glob(golden_path)[0]
compare_images(test_file, golden_file)
else:
print(" ".join(command))
print("failed to generate image for this configuration")


parser = argparse.ArgumentParser()
Expand Down

0 comments on commit 157ae64

Please sign in to comment.