Update README.md
Browse files
README.md
CHANGED
@@ -27,25 +27,31 @@ cnn_model = tf.keras.models.load_model(model_path)
|
|
27 |
def preprocess_image(image_path):
|
28 |
try:
|
29 |
img = Image.open(image_path).convert('RGB')
|
30 |
-
img = img.resize((
|
31 |
-
img_array = np.array(img) / 255.0
|
32 |
-
img_array = np.expand_dims(img_array, axis=0)
|
33 |
return img_array
|
34 |
except Exception as e:
|
35 |
print(f"Error processing image: {e}")
|
|
|
36 |
|
37 |
-
#
|
38 |
-
def
|
39 |
img_array = preprocess_image(image_path)
|
40 |
if img_array is not None:
|
41 |
-
predictions = cnn_model.predict(img_array)
|
42 |
-
|
|
|
|
|
|
|
|
|
43 |
else:
|
44 |
-
return "
|
45 |
|
46 |
# ํ
์คํธ ์ด๋ฏธ์ง ์์ธก
|
47 |
-
image_path = r'
|
48 |
-
|
49 |
-
print(
|
|
|
50 |
|
51 |
```
|
|
|
27 |
def preprocess_image(image_path):
|
28 |
try:
|
29 |
img = Image.open(image_path).convert('RGB')
|
30 |
+
img = img.resize((152, 152)) # ๋ชจ๋ธ์ด ์๊ตฌํ๋ ํฌ๊ธฐ
|
31 |
+
img_array = np.array(img) / 255.0 # ์ด๋ฏธ์ง๋ฅผ 0-1 ์ฌ์ด๋ก ์ ๊ทํ
|
32 |
+
img_array = np.expand_dims(img_array, axis=0) # ๋ฐฐ์น ์ฐจ์ ์ถ๊ฐ
|
33 |
return img_array
|
34 |
except Exception as e:
|
35 |
print(f"Error processing image: {e}")
|
36 |
+
return None
|
37 |
|
38 |
+
# ์ ์ฌ๋ ์์ธก ํจ์
|
39 |
+
def predict_similarity(image_path):
|
40 |
img_array = preprocess_image(image_path)
|
41 |
if img_array is not None:
|
42 |
+
predictions = cnn_model.predict(img_array) # ๋ชจ๋ธ์ ํตํด ์์ธก
|
43 |
+
similarity_score = np.mean(predictions) # ์ ์ฌ๋ ์ ์์ ํ๊ท ๊ณ์ฐ
|
44 |
+
if similarity_score > 0.5: # ์๊ณ๊ฐ์ ๊ธฐ์ค์ผ๋ก ์ ์ฌ๋ ํ๋จ
|
45 |
+
return "๋ก๋งจ์ค ์ค์บ ์ด๋ฏธ์ง์
๋๋ค."
|
46 |
+
else:
|
47 |
+
return "๋ก๋งจ์ค ์ค์บ ์ด๋ฏธ์ง๊ฐ ์๋๋๋ค."
|
48 |
else:
|
49 |
+
return "์ด๋ฏธ์ง ์ ์ฒ๋ฆฌ์ ์คํจํ์ต๋๋ค."
|
50 |
|
51 |
# ํ
์คํธ ์ด๋ฏธ์ง ์์ธก
|
52 |
+
image_path = r'์ฌ์ง ์์น ์
๋ ฅ' # ํ
์คํธํ ์ด๋ฏธ์ง ๊ฒฝ๋ก
|
53 |
+
result = predict_similarity(image_path)
|
54 |
+
print(result)
|
55 |
+
|
56 |
|
57 |
```
|