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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -4
app.py CHANGED
@@ -1,11 +1,16 @@
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,7 +23,7 @@ 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 "❌ กรุณาอัปโหลดภาพทั้งสองภาพ"
 
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
  import gradio as gr
7
 
8
+ def absolute_difference(x):
9
+ return tf.abs(x[0] - x[1])
10
+
11
+ # ตรวจสอบว่าไฟล์อยู่ที่นี่จริง
12
+ with CustomObjectScope({'absolute_difference': absolute_difference}):
13
+ model = TFAutoModel.from_pretrained("Nithikorn/Signature_Detection")
14
  print("✅ โมเดลโหลดสำเร็จ!")
15
 
16
  def preprocess_image(image):
 
23
  # ฟังก์ชันเปรียบเทียบลายเซ็น
24
  def predict_signature(image1, image2):
25
  print("เริ่มการทำนาย...")
26
+
27
  if image1 is None or image2 is None:
28
  print("ไม่พบรูปภาพ")
29
  return "❌ กรุณาอัปโหลดภาพทั้งสองภาพ"