Update app.py
Browse files
app.py
CHANGED
@@ -36,11 +36,14 @@ def classify_image(input_image):
|
|
36 |
image = Image.fromarray(input_image.astype('uint8'))
|
37 |
|
38 |
# Criar uma imagem com o rótulo de previsão sobreposta no centro
|
39 |
-
draw = ImageDraw.Draw(image)
|
40 |
width, height = image.size
|
41 |
font = ImageFont.load_default()
|
42 |
text = f'Previsão: {predicted_class_label}'
|
43 |
-
|
|
|
|
|
|
|
44 |
x = (width - text_width) // 2
|
45 |
y = (height - text_height) // 2
|
46 |
draw.text((x, y), text, fill='white', font=font)
|
@@ -48,6 +51,8 @@ def classify_image(input_image):
|
|
48 |
# Converter a imagem resultante de volta para numpy
|
49 |
result_image = np.array(image)
|
50 |
return result_image
|
|
|
|
|
51 |
|
52 |
# Criar uma interface Gradio
|
53 |
interface = gr.Interface(
|
|
|
36 |
image = Image.fromarray(input_image.astype('uint8'))
|
37 |
|
38 |
# Criar uma imagem com o rótulo de previsão sobreposta no centro
|
39 |
+
draw = ImageDraw.Draw(image)
|
40 |
width, height = image.size
|
41 |
font = ImageFont.load_default()
|
42 |
text = f'Previsão: {predicted_class_label}'
|
43 |
+
|
44 |
+
# Obter o tamanho do texto
|
45 |
+
text_width, text_height = draw.textsize(text, font=font)
|
46 |
+
|
47 |
x = (width - text_width) // 2
|
48 |
y = (height - text_height) // 2
|
49 |
draw.text((x, y), text, fill='white', font=font)
|
|
|
51 |
# Converter a imagem resultante de volta para numpy
|
52 |
result_image = np.array(image)
|
53 |
return result_image
|
54 |
+
# ...
|
55 |
+
|
56 |
|
57 |
# Criar uma interface Gradio
|
58 |
interface = gr.Interface(
|