PrashantGoyal commited on
Commit
725b653
·
1 Parent(s): b0af588

minor bugs fixed

Browse files
Files changed (2) hide show
  1. App/app.py +24 -23
  2. src/training.py +7 -6
App/app.py CHANGED
@@ -16,6 +16,9 @@ import base64
16
  from io import BytesIO
17
  import threading
18
  from datetime import timedelta
 
 
 
19
  warnings.filterwarnings("ignore", message=".*QuickGELU mismatch.*")
20
 
21
 
@@ -66,7 +69,6 @@ def decode_jwt(fn):
66
  })
67
  else:
68
  id=decode_token(token)["sub"]
69
- print(id)
70
  return fn(user_id=id, *args, **kwargs)
71
  return wrapper
72
 
@@ -110,7 +112,7 @@ def register():
110
 
111
  return jsonify({
112
  "success":False,
113
- "error":"User Already Exist"
114
  })
115
  hashing=bcrypt.generate_password_hash(password).decode("utf-8")
116
  new_user=db.table("users").insert({"first_name":first_name,"last_name":last_name,"email":email,"phone":phone,"password":hashing}).execute().data[0]
@@ -174,10 +176,10 @@ def get_user(user_id):
174
  user=user= db.table("users").select("*").eq("id",user_id).limit(1).execute().data[0]
175
  return jsonify({
176
  "success":True,
177
- "user":{"first_name": user.first_name,
178
- "last_name": user.last_name,
179
- "email": user.email,
180
- "phone_number": user.phone}
181
  }), 200
182
 
183
 
@@ -282,23 +284,22 @@ def foundItem(user_id):
282
  @decode_jwt
283
  def allLostItems(user_id):
284
 
285
- rows = db.table("lostItem").select("*").eq("user_id",user_id).execute().data
286
- items = [DotDict(r) for r in rows]
287
  output = []
288
- for item in items[0]:
289
  output.append({
290
- "id": item.id,
291
- "name": item.name,
292
- "email": item.email,
293
- "phone": item.phone,
294
- "description": item.description,
295
- "lastSeenLocation": item.lastSeenLocation,
296
- "dateTimeLost": item.dateTimeLost,
297
- "reward": item.reward,
298
- "additionalNotes": item.additionalNotes,
299
- "image_url": item.image_url,
300
- "status": item.status,
301
- "created_at": item.created_at
302
  })
303
  return jsonify({
304
  "success":True,
@@ -402,7 +403,7 @@ def lostMatchDetail(lost_id):
402
  @app.route('/allFoundItems',methods=['GET'])
403
  @decode_jwt
404
  def allFoundItems(user_id):
405
- items = db.table("foundItem").select("*").eq("user_id",user_id).execute().data[0]
406
  output = []
407
  for item in items:
408
  output.append({
@@ -424,7 +425,7 @@ def allFoundItems(user_id):
424
  @app.route('/foundMatchDetail/<lost_id>',methods=['GET'])
425
  def foundMatchDetail(lost_id):
426
  found_item = db.table("foundItem").select("*").eq("id",lost_id).limit(1).execute().data[0]
427
- print(lost_id)
428
  found_items=[]
429
  if not found_item:
430
  return jsonify({
 
16
  from io import BytesIO
17
  import threading
18
  from datetime import timedelta
19
+ import json
20
+ from dotenv import load_dotenv
21
+ load_dotenv()
22
  warnings.filterwarnings("ignore", message=".*QuickGELU mismatch.*")
23
 
24
 
 
69
  })
70
  else:
71
  id=decode_token(token)["sub"]
 
72
  return fn(user_id=id, *args, **kwargs)
73
  return wrapper
74
 
 
112
 
113
  return jsonify({
114
  "success":False,
115
+ "message":"User Already Exist"
116
  })
117
  hashing=bcrypt.generate_password_hash(password).decode("utf-8")
118
  new_user=db.table("users").insert({"first_name":first_name,"last_name":last_name,"email":email,"phone":phone,"password":hashing}).execute().data[0]
 
176
  user=user= db.table("users").select("*").eq("id",user_id).limit(1).execute().data[0]
177
  return jsonify({
178
  "success":True,
179
+ "user":{"first_name": user.get("first_name"),
180
+ "last_name": user.get("last_name"),
181
+ "email": user.get("email"),
182
+ "phone_number": user.get("phone")}
183
  }), 200
184
 
185
 
 
284
  @decode_jwt
285
  def allLostItems(user_id):
286
 
287
+ items = db.table("lostItem").select("*").eq("user_id",user_id).execute().data
 
288
  output = []
289
+ for item in items:
290
  output.append({
291
+ "id": item.get("id"),
292
+ "name": item.get("name"),
293
+ "email": item.get("email"),
294
+ "phone": item.get("phone"),
295
+ "description": item.get("description"),
296
+ "lastSeenLocation": item.get("lastSeenLocation"),
297
+ "dateTimeLost": item.get("dateTimeLost"),
298
+ "reward": item.get("reward"),
299
+ "additionalNotes": item.get("additionalNotes"),
300
+ "image_url": item.get("image_url"),
301
+ "status": item.get("status"),
302
+ "created_at": item.get("created_at")
303
  })
304
  return jsonify({
305
  "success":True,
 
403
  @app.route('/allFoundItems',methods=['GET'])
404
  @decode_jwt
405
  def allFoundItems(user_id):
406
+ items = db.table("foundItem").select("*").eq("user_id",user_id).execute().data
407
  output = []
408
  for item in items:
409
  output.append({
 
425
  @app.route('/foundMatchDetail/<lost_id>',methods=['GET'])
426
  def foundMatchDetail(lost_id):
427
  found_item = db.table("foundItem").select("*").eq("id",lost_id).limit(1).execute().data[0]
428
+
429
  found_items=[]
430
  if not found_item:
431
  return jsonify({
src/training.py CHANGED
@@ -21,12 +21,13 @@ HF_TOKEN=os.getenv("HF_TOKEN")
21
 
22
  MODEL_ID = "PrashantGoyal/findr-clip-ft"
23
 
24
- model_path = hf_hub_download(
25
- repo_id=MODEL_ID,
26
- force_download=True,
27
- filename="clip/best.pt",
28
- token=os.getenv("HF_TOKEN")
29
- )
 
30
  tokenizer=open_clip.get_tokenizer('ViT-B-32')
31
 
32
  def seed_everything(seed=42):
 
21
 
22
  MODEL_ID = "PrashantGoyal/findr-clip-ft"
23
 
24
+ # model_path = hf_hub_download(
25
+ # repo_id=MODEL_ID,
26
+ # force_download=True,
27
+ # filename="clip/best.pt",
28
+ # token=os.getenv("HF_TOKEN")
29
+ # )
30
+ model_path = "model/clip/best.pt"
31
  tokenizer=open_clip.get_tokenizer('ViT-B-32')
32
 
33
  def seed_everything(seed=42):