-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinferencia.py
51 lines (43 loc) · 1.29 KB
/
inferencia.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# -*- coding: utf-8 -*-
import os
os.environ["CUDA_VISIBLE_DEVICES"]="1"
import tensorflow as tf
#config = tf.compat.v1.ConfigProto()
#config.gpu_options.allow_growth = True
#tf.compat.v1.keras.backend.set_session(tf.compat.v1.Session(config=config))
path = '.'
#import psutil
#import humanize
import os
import matplotlib.pyplot as plt
from imutils import paths
import seaborn as sns
import pandas as pd
import numpy as np
import cv2
import keras
from tensorflow.keras.models import model_from_json
#from tensorflow.keras.optimizers import Adam, Adagrad
#from tensorflow.keras.utils import to_categorical
#from tensorflow.keras.applications import preprocess_input
init_lr = 1e-3
epochs = 100
batch_size = 5
json_file = open('modelo.json', 'r')
loaded_model_json = json_file.read()
json_file.close()
loaded_model = model_from_json(loaded_model_json)
# load weights into new model
loaded_model.load_weights("modelo.h5")
print("Loaded model from disk")
#label = to_categorical('1')
image = cv2.imread("covid.png")
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
image = cv2.resize(image, (256, 256))
data = np.array(np.expand_dims(image, axis=0))/255.0
predIdxs = [loaded_model.predict(data)[0][::-1]]
predIdxs = np.argmax(predIdxs, axis=1)
if predIdxs[0]== 1:
print("tem covid-19")
else:
print("não tem covid-19")