Update README.md

#1
by FernFox - opened
Files changed (1) hide show
  1. README.md +50 -0
README.md CHANGED
@@ -79,3 +79,53 @@ This section has moved here: [https://facebook.github.io/create-react-app/docs/d
79
  ### `npm run build` fails to minify
80
 
81
  This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  ### `npm run build` fails to minify
80
 
81
  This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
82
+
83
+ # Install:
84
+ # pip install transformers torch pillow duckduckgo-search
85
+
86
+ from transformers import pipeline
87
+ from PIL import Image
88
+ from duckduckgo_search import DDGS
89
+
90
+ print("😊 Starting FaceMatch AI...")
91
+
92
+ # AI that describes images
93
+ vision_ai = pipeline(
94
+ "image-to-text",
95
+ model="Salesforce/blip-image-captioning-base"
96
+ )
97
+
98
+ def search_face_image(photo_path):
99
+ print("\n😊 Hey! Let's look at your image.")
100
+
101
+ try:
102
+ image = Image.open(photo_path).convert("RGB")
103
+
104
+ print("🔎 Analyzing the image...")
105
+ description = vision_ai(image)[0]["generated_text"]
106
+
107
+ print(f"🧠 Image details: {description}")
108
+ print("🌐 Searching for related public webpages...")
109
+
110
+ with DDGS() as search:
111
+ results = list(search.text(
112
+ description,
113
+ max_results=10
114
+ ))
115
+
116
+ if results:
117
+ print("\n😊 Yay! I found some relevant search results!")
118
+
119
+ for i, result in enumerate(results, 1):
120
+ print(f"\n📄 Result {i}: {result['title']}")
121
+ print(f"🔗 Link: {result['href']}")
122
+ print(f"📝 {result['body']}")
123
+ else:
124
+ print("🙂 No results this time. Let's try another image.")
125
+
126
+ except Exception as error:
127
+ print(f"😕 Something went wrong: {error}")
128
+
129
+ if __name__ == "__main__":
130
+ photo = input("📷 Enter the path to your image: ")
131
+ search_face_image(photo)