Spaces:
Running
Running
Download pydraw3d/check.py from HuggingFaceSwarms/pydraw: direct link, hf CLI and curl.
- Browser
- Download file 1.37 kB
-
https://huggingface.co/spaces/HuggingFaceSwarms/pydraw/resolve/main/pydraw3d/check.py
- Command line
-
hf download hf://spaces/HuggingFaceSwarms/pydraw/pydraw3d/check.py
-
curl -L -o check.py https://huggingface.co/spaces/HuggingFaceSwarms/pydraw/resolve/main/pydraw3d/check.py
1.37 kB
| """Judge check for 3D models: unprompted naming + look rating + caption match, batched in one GPU process. | |
| python -m pydraw3d.check giraffe zebra ... [--prompts "a photo of two giraffes" ...] | |
| Prints per prompt/seed: the judge's unprompted name, look (1-10), caption match P(yes).""" | |
| import sys, os | |
| sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "bench")) | |
| def main(): | |
| args = sys.argv[1:] | |
| extra = [] | |
| if "--prompts" in args: | |
| i = args.index("--prompts") | |
| extra, args = args[i + 1:], args[:i] | |
| prompts = ["a photo of a %s" % n for n in args] + extra | |
| from pydraw3d import plot3d | |
| ims = [(p, s, plot3d(p, seed=s).convert("RGB")) for p in prompts for s in (0, 1)] | |
| from judge import Judge | |
| J = Judge() | |
| names = J.short([(im, "What is the main subject of this picture? Answer with the most specific common name, one to three words.") for _, _, im in ims], max_new=8) | |
| looks = J.rating([im for _, _, im in ims]) | |
| match = J.yesno([(im, 'Does this image match the caption: "%s"?' % p) for p, _, im in ims]) | |
| for (p, s, _), n, l, m in zip(ims, names, looks, match): | |
| print("%-40s seed%d name=%-22s look=%.2f match=%.2f" % (p, s, n, l, m)) | |
| print("MEAN look %.2f match %.3f" % (sum(looks) / len(looks), sum(match) / len(match))) | |
| if __name__ == "__main__": | |
| main() | |