Spaces:
Configuration error
Configuration error
Download app.py from FernFox/Juliet: direct link, hf CLI and curl.
- Browser
- Download file 1.44 kB
-
https://huggingface.co/spaces/FernFox/Juliet/resolve/main/app.py
- Command line
-
hf download hf://spaces/FernFox/Juliet/app.py
-
curl -L -o app.py https://huggingface.co/spaces/FernFox/Juliet/resolve/main/app.py
1.44 kB
| # Install: | |
| # pip install transformers torch pillow duckduckgo-search | |
| from transformers import pipeline | |
| from PIL import Image | |
| from duckduckgo_search import DDGS | |
| print("π Starting FaceMatch AI...") | |
| # AI that describes images | |
| vision_ai = pipeline( | |
| "image-to-text", | |
| model="Salesforce/blip-image-captioning-base" | |
| ) | |
| def search_face_image(photo_path): | |
| print("\nπ Hey! Let's look at your image.") | |
| try: | |
| image = Image.open(photo_path).convert("RGB") | |
| print("π Analyzing the image...") | |
| description = vision_ai(image)[0]["generated_text"] | |
| print(f"π§ Image details: {description}") | |
| print("π Searching for related public webpages...") | |
| with DDGS() as search: | |
| results = list(search.text( | |
| description, | |
| max_results=10 | |
| )) | |
| if results: | |
| print("\nπ Yay! I found some relevant search results!") | |
| for i, result in enumerate(results, 1): | |
| print(f"\nπ Result {i}: {result['title']}") | |
| print(f"π Link: {result['href']}") | |
| print(f"π {result['body']}") | |
| else: | |
| print("π No results this time. Let's try another image.") | |
| except Exception as error: | |
| print(f"π Something went wrong: {error}") | |
| if __name__ == "__main__": | |
| photo = input("π· Enter the path to your image: ") | |
| search_face_image(photo) | |