Spaces:
Runtime error
Runtime error
Download anything2image/cli.py from ZeqiangLai/Anything2Image: direct link, hf CLI and curl.
- Browser
- Download file 648 Bytes
-
https://huggingface.co/spaces/ZeqiangLai/Anything2Image/resolve/main/anything2image/cli.py
- Command line
-
hf download hf://spaces/ZeqiangLai/Anything2Image/anything2image/cli.py
-
curl -L -o cli.py https://huggingface.co/spaces/ZeqiangLai/Anything2Image/resolve/main/anything2image/cli.py
648 Bytes
| import os | |
| import fire | |
| from anything2image.api import Anything2Image | |
| import soundfile as sf | |
| from PIL import Image | |
| import numpy as np | |
| def main( | |
| prompt='', audio=None, image=None, text=None, | |
| ckpt_dir=os.path.join(os.path.expanduser('~'), 'anything2image', 'checkpoints') | |
| ): | |
| anything2img = Anything2Image(imagebind_download_dir=ckpt_dir) | |
| if audio is not None: | |
| data, samplerate = sf.read(audio) | |
| audio = (samplerate, data) | |
| if image is not None: | |
| image = np.array(Image.open(image)) | |
| image = anything2img(prompt=prompt, audio=audio, image=image, text=text) | |
| image.save('cli_output.png') | |
| fire.Fire(main) |