valencar commited on
Commit
0fc7b4d
·
1 Parent(s): 9bdd240
Files changed (1) hide show
  1. app.py +9 -25
app.py CHANGED
@@ -29,48 +29,32 @@ def predict_image(name_image):
29
  categories = ['Normal', 'Tuberculose']
30
  url_image = './'
31
 
32
- # './' + name_image
33
-
34
- # from huggingface_hub import HfFileSystem
35
- # model_repo = 'valencar/modelo_raios_x'
36
- #fs = HfFileSystem()
37
- #file_hf = "hf://valencar/modelo_raios_x/dados_teste/" + name_image
38
-
39
- # from datasets import Dataset, Image
40
- # dataset = Dataset.from_dict({"image": ["path/to/image_1", "path/to/image_2", ..., "path/to/image_n"]}).cast_column("image", Image())
41
- # image_hf = dataset[0]["image"]
42
- # <PIL.PngImagePlugin.PngImageFile image mode=RGBA size=1200x215 at 0x15E6D7160>]
43
-
44
-
45
-
46
- # image_hf = "valencar/modelo_raios_x/dados_teste/" + name_image
47
 
48
  # image_hf = "valencar/modelo_raios_x/dados_teste/" + "CHNCXR_0001_0.png"
49
 
50
-
51
  from PIL import Image
52
  import requests
53
 
54
-
55
-
56
  # url = "https://huggingface.co/valencar/modelo_raios_x/blob/main/dados_teste/CHNCXR_0001_0.png"
57
 
58
  # req = requests.get(url, stream=True).raw
59
  # #image_hf = Image.open(req)
60
  # image_hf = req
61
 
62
- imagem = Image.open(name_image)
63
- imagem.save("image_raiox","png")
64
- nome_imagem_salva = 'image_raiox.png'
65
- image_hf = nome_imagem_salva
 
 
66
 
67
- img = img_orig = image.load_img(image_hf, target_size = (IMAGE_HEIGHT, IMAGE_WIDTH))
68
  img = image.img_to_array(img)
69
  img = np.expand_dims(img, axis = 0)
70
  img = img/255.0
 
71
 
72
-
73
- col1.image(image_hf, width=450)
74
 
75
  pred = st.session_state.model.predict(img)
76
  classe = np.argmax(pred)
 
29
  categories = ['Normal', 'Tuberculose']
30
  url_image = './'
31
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
 
33
  # image_hf = "valencar/modelo_raios_x/dados_teste/" + "CHNCXR_0001_0.png"
34
 
 
35
  from PIL import Image
36
  import requests
37
 
 
 
38
  # url = "https://huggingface.co/valencar/modelo_raios_x/blob/main/dados_teste/CHNCXR_0001_0.png"
39
 
40
  # req = requests.get(url, stream=True).raw
41
  # #image_hf = Image.open(req)
42
  # image_hf = req
43
 
44
+ hf_home = '/root/.cache/huggingface/'
45
+
46
+ # imagem = Image.open(hf_home + name_image)
47
+ # imagem.save("image_raiox","png")
48
+ # nome_imagem_salva = 'image_raiox.png'
49
+ # image_hf = nome_imagem_salva
50
 
51
+ img = img_orig = image.load_img(hf_home + name_image, target_size = (IMAGE_HEIGHT, IMAGE_WIDTH))
52
  img = image.img_to_array(img)
53
  img = np.expand_dims(img, axis = 0)
54
  img = img/255.0
55
+
56
 
57
+ col1.image(hf_home + name_image, width=450)
 
58
 
59
  pred = st.session_state.model.predict(img)
60
  classe = np.argmax(pred)