Jon Solow commited on
Commit
32804a1
Β·
1 Parent(s): f68d424

Refactor name to huggingface_client

Browse files
src/{huggingface β†’ huggingface_client}/__init__.py RENAMED
File without changes
src/{huggingface β†’ huggingface_client}/handler.py RENAMED
File without changes
src/{huggingface β†’ huggingface_client}/labels.py RENAMED
File without changes
src/{huggingface β†’ huggingface_client}/model.py RENAMED
File without changes
src/{huggingface β†’ huggingface_client}/predict.py RENAMED
File without changes
src/model_client.py CHANGED
@@ -1,15 +1,10 @@
1
- from time import time
2
  from typing import List, Optional, Tuple, Union
3
- import json
4
- import os
5
- import requests
6
- from urllib.parse import urljoin
7
 
8
  from django.core.files.uploadedfile import InMemoryUploadedFile, TemporaryUploadedFile
9
 
10
  import logging
11
 
12
- from huggingface.predict import predict_file, predict_url
13
 
14
 
15
 
@@ -23,10 +18,7 @@ def url_image_vars(
23
  input_img: Union[str, InMemoryUploadedFile, TemporaryUploadedFile], label: str
24
  ) -> Tuple[List[str], List[str]]:
25
  actual_label = label.title()
26
- if not is_healthy():
27
- logging.error("Model failed healthcheck")
28
- top_guesses = ["Model Offline", "Try Again Later", "", "", ""]
29
- elif isinstance(input_img, str):
30
  top_guesses = predict_url(input_img)
31
  elif isinstance(input_img, (InMemoryUploadedFile, TemporaryUploadedFile)):
32
  input_img.seek(0)
@@ -37,6 +29,3 @@ def url_image_vars(
37
  color_labels = get_color_labels(top_guesses, actual_label)
38
  return top_guesses, color_labels
39
 
40
-
41
- def is_healthy() -> bool:
42
- return True
 
 
1
  from typing import List, Optional, Tuple, Union
 
 
 
 
2
 
3
  from django.core.files.uploadedfile import InMemoryUploadedFile, TemporaryUploadedFile
4
 
5
  import logging
6
 
7
+ from huggingface_client.predict import predict_file, predict_url
8
 
9
 
10
 
 
18
  input_img: Union[str, InMemoryUploadedFile, TemporaryUploadedFile], label: str
19
  ) -> Tuple[List[str], List[str]]:
20
  actual_label = label.title()
21
+ if isinstance(input_img, str):
 
 
 
22
  top_guesses = predict_url(input_img)
23
  elif isinstance(input_img, (InMemoryUploadedFile, TemporaryUploadedFile)):
24
  input_img.seek(0)
 
29
  color_labels = get_color_labels(top_guesses, actual_label)
30
  return top_guesses, color_labels
31