Download Auto-Photoshop-StableDiffusion-Plugin/server/python_server/search.py from toto10/extensions: direct link, hf CLI and curl.
- Browser
- Download file 536 Bytes
-
https://huggingface.co/toto10/extensions/resolve/refs%2Fpr%2F4/Auto-Photoshop-StableDiffusion-Plugin/server/python_server/search.py
- Command line
-
hf download hf://toto10/extensions@refs/pr/4/Auto-Photoshop-StableDiffusion-Plugin/server/python_server/search.py
-
curl -L -o search.py https://huggingface.co/toto10/extensions/resolve/refs%2Fpr%2F4/Auto-Photoshop-StableDiffusion-Plugin/server/python_server/search.py
536 Bytes
| from itertools import islice | |
| try: | |
| from duckduckgo_search import DDGS | |
| except ImportError: | |
| raise ImportError( | |
| "duckduckgo_search is required to image search. Please install it with `pip install --upgrade duckduckgo_search`." | |
| ) | |
| async def imageSearch(keywords="cute cats"): | |
| with DDGS() as ddgs: | |
| return [x for x in islice(ddgs.images(keywords), 30)] | |
| if __name__ == "__main__": | |
| async def main(): | |
| result = await imageSearch() | |
| print(result) | |
| import asyncio | |
| asyncio.run(main()) | |