Nithikorn commited on
Commit
5b24d89
·
verified ·
1 Parent(s): c452964

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -12
app.py CHANGED
@@ -1,19 +1,11 @@
1
  import tensorflow as tf
2
  import numpy as np
3
- from tensorflow.keras.models import load_model
4
- from tensorflow.keras.utils import CustomObjectScope
5
- from PIL import Image
6
  from transformers import TFAutoModel
 
7
  import gradio as gr
8
 
9
- def absolute_difference(x):
10
- return tf.abs(x[0] - x[1])
11
-
12
- model_path = "huggingface_Nithikorn/Signature_Detection"
13
-
14
- # ตรวจสอบว่าไฟล์อยู่ที่นี่จริง
15
- with CustomObjectScope({'absolute_difference': absolute_difference}):
16
- model = load_model(model_path)
17
  print("✅ โมเดลโหลดสำเร็จ!")
18
 
19
  def preprocess_image(image):
@@ -26,7 +18,7 @@ def preprocess_image(image):
26
  # ฟังก์ชันเปรียบเทียบลายเซ็น
27
  def predict_signature(image1, image2):
28
  print("เริ่มการทำนาย...")
29
-
30
  if image1 is None or image2 is None:
31
  print("ไม่พบรูปภาพ")
32
  return "❌ กรุณาอัปโหลดภาพทั้งสองภาพ"
 
1
  import tensorflow as tf
2
  import numpy as np
 
 
 
3
  from transformers import TFAutoModel
4
+ from PIL import Image
5
  import gradio as gr
6
 
7
+ # โหลดโมเดลจาก Hugging Face
8
+ model = TFAutoModel.from_pretrained("huggingface_Nithikorn/Signature_Detection")
 
 
 
 
 
 
9
  print("✅ โมเดลโหลดสำเร็จ!")
10
 
11
  def preprocess_image(image):
 
18
  # ฟังก์ชันเปรียบเทียบลายเซ็น
19
  def predict_signature(image1, image2):
20
  print("เริ่มการทำนาย...")
21
+
22
  if image1 is None or image2 is None:
23
  print("ไม่พบรูปภาพ")
24
  return "❌ กรุณาอัปโหลดภาพทั้งสองภาพ"