Spaces:
Sleeping
Sleeping
redone the classification app
Browse files- .history/app_20240615164806.py +92 -0
- .history/app_20240617174335.py +82 -0
- .history/app_20240617174401.py +81 -0
- .history/app_20240617174710.py +65 -0
- .history/app_20240617174712.py +66 -0
- .history/app_20240617174718.py +68 -0
- .history/app_20240617174723.py +69 -0
- .history/app_20240617174727.py +70 -0
- .history/app_20240617174736.py +69 -0
- .history/app_20240617175003.py +71 -0
- .history/app_20240617175116.py +67 -0
- .history/app_20240617175159.py +67 -0
- .history/app_20240617175308.py +67 -0
- .history/app_20240617175426.py +67 -0
- .history/app_20240617175718.py +67 -0
- .history/app_20240617175727.py +71 -0
- .history/app_20240617175737.py +72 -0
- .history/app_20240617175752.py +72 -0
- .history/app_20240617175811.py +72 -0
- .history/app_20240617175818.py +72 -0
- .history/app_20240617175857.py +72 -0
- .history/app_20240617175900.py +72 -0
- .history/app_20240617175913.py +72 -0
- .history/app_20240617175920.py +72 -0
- .history/app_20240617175957.py +72 -0
- .history/app_20240617180016.py +72 -0
- app.py +70 -1
- examples/Bacterial.jpeg +0 -0
- examples/Normal.jpeg +0 -0
- examples/Viral.jpeg +0 -0
- models/config.json +34 -0
- models/model.safetensors +3 -0
- models/optimizer.pt +3 -0
- models/preprocessor_config.json +22 -0
- models/rng_state.pth +3 -0
- models/scheduler.pt +3 -0
- models/trainer_state.json +1551 -0
- models/training_args.bin +3 -0
.history/app_20240615164806.py
ADDED
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import gradio as gr
|
3 |
+
from PIL import Image
|
4 |
+
import torch
|
5 |
+
import torchvision.transforms as transforms
|
6 |
+
from transformers import ViTForImageClassification, ViTImageProcessor
|
7 |
+
from datasets import load_dataset
|
8 |
+
|
9 |
+
# Model and processor configuration
|
10 |
+
model_name_or_path = "google/vit-base-patch16-224-in21k"
|
11 |
+
processor = ViTImageProcessor.from_pretrained(model_name_or_path)
|
12 |
+
|
13 |
+
# Load dataset (adjust dataset_path accordingly)
|
14 |
+
dataset_path = "pawlo2013/chest_xray"
|
15 |
+
train_dataset = load_dataset(dataset_path, split="train")
|
16 |
+
class_names = train_dataset.features["label"].names
|
17 |
+
|
18 |
+
# Load ViT model
|
19 |
+
model = ViTForImageClassification.from_pretrained(
|
20 |
+
"./models",
|
21 |
+
num_labels=len(class_names),
|
22 |
+
id2label={str(i): label for i, label in enumerate(class_names)},
|
23 |
+
label2id={label: i for i, label in enumerate(class_names)},
|
24 |
+
)
|
25 |
+
|
26 |
+
# Set model to evaluation mode
|
27 |
+
model.eval()
|
28 |
+
|
29 |
+
# Define transformation for incoming images
|
30 |
+
transform = transforms.Compose(
|
31 |
+
[
|
32 |
+
transforms.Resize((224, 224)), # Resize to model's expected input size
|
33 |
+
transforms.ToTensor(),
|
34 |
+
transforms.Normalize(
|
35 |
+
mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]
|
36 |
+
), # Normalization
|
37 |
+
]
|
38 |
+
)
|
39 |
+
|
40 |
+
|
41 |
+
# Function to predict on a single image
|
42 |
+
def classify_image(img):
|
43 |
+
img = processor(img.convert("RGB")) # Apply ViT processor
|
44 |
+
img = transform(img) # Apply transformations
|
45 |
+
img = img.unsqueeze(0) # Add batch dimension
|
46 |
+
with torch.no_grad():
|
47 |
+
output = model(img) # Forward pass through the model
|
48 |
+
_, predicted = torch.max(output, 1) # Get predicted class index
|
49 |
+
return class_names[predicted.item()] # Return predicted class label
|
50 |
+
|
51 |
+
|
52 |
+
# Function to process all images in a folder
|
53 |
+
def classify_all_images():
|
54 |
+
examples_dir = "examples"
|
55 |
+
results = []
|
56 |
+
for filename in os.listdir(examples_dir):
|
57 |
+
if filename.endswith(".jpg") or filename.endswith(".png"):
|
58 |
+
img_path = os.path.join(examples_dir, filename)
|
59 |
+
img = Image.open(img_path)
|
60 |
+
img = processor(img.convert("RGB")) # Apply ViT processor
|
61 |
+
img = transform(img) # Apply transformations
|
62 |
+
img = img.unsqueeze(0) # Add batch dimension
|
63 |
+
with torch.no_grad():
|
64 |
+
output = model(img)
|
65 |
+
_, predicted = torch.max(output, 1)
|
66 |
+
results.append(
|
67 |
+
(filename, class_names[predicted.item()])
|
68 |
+
) # Store filename and predicted class label
|
69 |
+
return results
|
70 |
+
|
71 |
+
|
72 |
+
# Create Gradio interface for single image classification
|
73 |
+
iface = gr.Interface(
|
74 |
+
fn=classify_image,
|
75 |
+
inputs=gr.inputs.Image(type="pil", label="Upload Image"),
|
76 |
+
outputs=gr.outputs.Label(num_top_classes=3),
|
77 |
+
title="Image Classification",
|
78 |
+
description="Classifies an image into one of the predefined classes.",
|
79 |
+
)
|
80 |
+
|
81 |
+
# Create Gradio interface for all images classification
|
82 |
+
iface_all_images = gr.Interface(
|
83 |
+
fn=classify_all_images,
|
84 |
+
inputs=None,
|
85 |
+
outputs=gr.outputs.Label(type="key_values", label="Image Classifications"),
|
86 |
+
title="Batch Image Classification",
|
87 |
+
description="Classifies all images in the 'examples' folder.",
|
88 |
+
)
|
89 |
+
|
90 |
+
# Launch both interfaces
|
91 |
+
iface.launch(share=True)
|
92 |
+
iface_all_images.launch(share=True)
|
.history/app_20240617174335.py
ADDED
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import gradio as gr
|
3 |
+
from PIL import Image
|
4 |
+
import torch
|
5 |
+
import torchvision.transforms as transforms
|
6 |
+
from transformers import ViTForImageClassification, ViTImageProcessor
|
7 |
+
from datasets import load_dataset
|
8 |
+
|
9 |
+
# Model and processor configuration
|
10 |
+
model_name_or_path = "google/vit-base-patch16-224-in21k"
|
11 |
+
processor = ViTImageProcessor.from_pretrained(model_name_or_path)
|
12 |
+
|
13 |
+
# Load dataset (adjust dataset_path accordingly)
|
14 |
+
dataset_path = "pawlo2013/chest_xray"
|
15 |
+
train_dataset = load_dataset(dataset_path, split="train")
|
16 |
+
class_names = train_dataset.features["label"].names
|
17 |
+
|
18 |
+
# Load ViT model
|
19 |
+
model = ViTForImageClassification.from_pretrained(
|
20 |
+
"./models",
|
21 |
+
num_labels=len(class_names),
|
22 |
+
id2label={str(i): label for i, label in enumerate(class_names)},
|
23 |
+
label2id={label: i for i, label in enumerate(class_names)},
|
24 |
+
)
|
25 |
+
|
26 |
+
# Set model to evaluation mode
|
27 |
+
model.eval()
|
28 |
+
|
29 |
+
# Define transformation for incoming images
|
30 |
+
|
31 |
+
|
32 |
+
# Function to predict on a single image
|
33 |
+
def classify_image(img):
|
34 |
+
img = processor(img.convert("RGB")) # Apply ViT processor
|
35 |
+
img = img.unsqueeze(0) # Add batch dimension
|
36 |
+
with torch.no_grad():
|
37 |
+
output = model(img) # Forward pass through the model
|
38 |
+
_, predicted = torch.max(output, 1) # Get predicted class index
|
39 |
+
return class_names[predicted.item()] # Return predicted class label
|
40 |
+
|
41 |
+
|
42 |
+
# Function to process all images in a folder
|
43 |
+
def classify_all_images():
|
44 |
+
examples_dir = "examples"
|
45 |
+
results = []
|
46 |
+
for filename in os.listdir(examples_dir):
|
47 |
+
if filename.endswith(".jpg") or filename.endswith(".png"):
|
48 |
+
img_path = os.path.join(examples_dir, filename)
|
49 |
+
img = Image.open(img_path)
|
50 |
+
img = processor(img.convert("RGB")) # Apply ViT processor
|
51 |
+
img = transform(img) # Apply transformations
|
52 |
+
img = img.unsqueeze(0) # Add batch dimension
|
53 |
+
with torch.no_grad():
|
54 |
+
output = model(img)
|
55 |
+
_, predicted = torch.max(output, 1)
|
56 |
+
results.append(
|
57 |
+
(filename, class_names[predicted.item()])
|
58 |
+
) # Store filename and predicted class label
|
59 |
+
return results
|
60 |
+
|
61 |
+
|
62 |
+
# Create Gradio interface for single image classification
|
63 |
+
iface = gr.Interface(
|
64 |
+
fn=classify_image,
|
65 |
+
inputs=gr.inputs.Image(type="pil", label="Upload Image"),
|
66 |
+
outputs=gr.outputs.Label(num_top_classes=3),
|
67 |
+
title="Image Classification",
|
68 |
+
description="Classifies an image into one of the predefined classes.",
|
69 |
+
)
|
70 |
+
|
71 |
+
# Create Gradio interface for all images classification
|
72 |
+
iface_all_images = gr.Interface(
|
73 |
+
fn=classify_all_images,
|
74 |
+
inputs=None,
|
75 |
+
outputs=gr.outputs.Label(type="key_values", label="Image Classifications"),
|
76 |
+
title="Batch Image Classification",
|
77 |
+
description="Classifies all images in the 'examples' folder.",
|
78 |
+
)
|
79 |
+
|
80 |
+
# Launch both interfaces
|
81 |
+
iface.launch(share=True)
|
82 |
+
iface_all_images.launch(share=True)
|
.history/app_20240617174401.py
ADDED
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import gradio as gr
|
3 |
+
from PIL import Image
|
4 |
+
import torch
|
5 |
+
import torchvision.transforms as transforms
|
6 |
+
from transformers import ViTForImageClassification, ViTImageProcessor
|
7 |
+
from datasets import load_dataset
|
8 |
+
|
9 |
+
# Model and processor configuration
|
10 |
+
model_name_or_path = "google/vit-base-patch16-224-in21k"
|
11 |
+
processor = ViTImageProcessor.from_pretrained(model_name_or_path)
|
12 |
+
|
13 |
+
# Load dataset (adjust dataset_path accordingly)
|
14 |
+
dataset_path = "pawlo2013/chest_xray"
|
15 |
+
train_dataset = load_dataset(dataset_path, split="train")
|
16 |
+
class_names = train_dataset.features["label"].names
|
17 |
+
|
18 |
+
# Load ViT model
|
19 |
+
model = ViTForImageClassification.from_pretrained(
|
20 |
+
"./models",
|
21 |
+
num_labels=len(class_names),
|
22 |
+
id2label={str(i): label for i, label in enumerate(class_names)},
|
23 |
+
label2id={label: i for i, label in enumerate(class_names)},
|
24 |
+
)
|
25 |
+
|
26 |
+
# Set model to evaluation mode
|
27 |
+
model.eval()
|
28 |
+
|
29 |
+
# Define transformation for incoming images
|
30 |
+
|
31 |
+
|
32 |
+
# Function to predict on a single image
|
33 |
+
def classify_image(img):
|
34 |
+
img = processor(img.convert("RGB")) # Apply ViT processor
|
35 |
+
img = img.unsqueeze(0) # Add batch dimension
|
36 |
+
with torch.no_grad():
|
37 |
+
output = model(img) # Forward pass through the model
|
38 |
+
_, predicted = torch.max(output, 1) # Get predicted class index
|
39 |
+
return class_names[predicted.item()] # Return predicted class label
|
40 |
+
|
41 |
+
|
42 |
+
# Function to process all images in a folder
|
43 |
+
def classify_all_images():
|
44 |
+
examples_dir = "examples"
|
45 |
+
results = []
|
46 |
+
for filename in os.listdir(examples_dir):
|
47 |
+
if filename.endswith(".jpg") or filename.endswith(".png"):
|
48 |
+
img_path = os.path.join(examples_dir, filename)
|
49 |
+
img = Image.open(img_path)
|
50 |
+
img = processor(img.convert("RGB")) # Apply ViT processor
|
51 |
+
img = img.unsqueeze(0) # Add batch dimension
|
52 |
+
with torch.no_grad():
|
53 |
+
output = model(img)
|
54 |
+
_, predicted = torch.max(output, 1)
|
55 |
+
results.append(
|
56 |
+
(filename, class_names[predicted.item()])
|
57 |
+
) # Store filename and predicted class label
|
58 |
+
return results
|
59 |
+
|
60 |
+
|
61 |
+
# Create Gradio interface for single image classification
|
62 |
+
iface = gr.Interface(
|
63 |
+
fn=classify_image,
|
64 |
+
inputs=gr.inputs.Image(type="pil", label="Upload Image"),
|
65 |
+
outputs=gr.outputs.Label(num_top_classes=3),
|
66 |
+
title="Image Classification",
|
67 |
+
description="Classifies an image into one of the predefined classes.",
|
68 |
+
)
|
69 |
+
|
70 |
+
# Create Gradio interface for all images classification
|
71 |
+
iface_all_images = gr.Interface(
|
72 |
+
fn=classify_all_images,
|
73 |
+
inputs=None,
|
74 |
+
outputs=gr.outputs.Label(type="key_values", label="Image Classifications"),
|
75 |
+
title="Batch Image Classification",
|
76 |
+
description="Classifies all images in the 'examples' folder.",
|
77 |
+
)
|
78 |
+
|
79 |
+
# Launch both interfaces
|
80 |
+
iface.launch(share=True)
|
81 |
+
iface_all_images.launch(share=True)
|
.history/app_20240617174710.py
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import gradio as gr
|
3 |
+
from PIL import Image
|
4 |
+
import torch
|
5 |
+
import torchvision.transforms as transforms
|
6 |
+
from transformers import ViTForImageClassification, ViTImageProcessor
|
7 |
+
from datasets import load_dataset
|
8 |
+
|
9 |
+
# Model and processor configuration
|
10 |
+
model_name_or_path = "google/vit-base-patch16-224-in21k"
|
11 |
+
processor = ViTImageProcessor.from_pretrained(model_name_or_path)
|
12 |
+
|
13 |
+
# Load dataset (adjust dataset_path accordingly)
|
14 |
+
dataset_path = "pawlo2013/chest_xray"
|
15 |
+
train_dataset = load_dataset(dataset_path, split="train")
|
16 |
+
class_names = train_dataset.features["label"].names
|
17 |
+
|
18 |
+
# Load ViT model
|
19 |
+
model = ViTForImageClassification.from_pretrained(
|
20 |
+
"./models",
|
21 |
+
num_labels=len(class_names),
|
22 |
+
id2label={str(i): label for i, label in enumerate(class_names)},
|
23 |
+
label2id={label: i for i, label in enumerate(class_names)},
|
24 |
+
)
|
25 |
+
|
26 |
+
# Set model to evaluation mode
|
27 |
+
model.eval()
|
28 |
+
|
29 |
+
# Define transformation for incoming images
|
30 |
+
|
31 |
+
|
32 |
+
def classify_image(img):
|
33 |
+
# Dummy classification function, replace with your model inference
|
34 |
+
|
35 |
+
processed_input = processor(images=img, return_tensors="pt")
|
36 |
+
|
37 |
+
return "Classified"
|
38 |
+
|
39 |
+
|
40 |
+
# Function to load examples from a folder
|
41 |
+
def load_examples_from_folder(folder_path):
|
42 |
+
examples = []
|
43 |
+
for file in os.listdir(folder_path):
|
44 |
+
if file.endswith((".png", ".jpg", ".jpeg")):
|
45 |
+
examples.append(os.path.join(folder_path, file))
|
46 |
+
return examples
|
47 |
+
|
48 |
+
|
49 |
+
# Define the path to the examples folder
|
50 |
+
examples_folder = "./examples"
|
51 |
+
examples = load_examples_from_folder(examples_folder)
|
52 |
+
|
53 |
+
# Create the Gradio interface
|
54 |
+
iface = gr.Interface(
|
55 |
+
fn=classify_image,
|
56 |
+
inputs=gr.Image(type="filepath"),
|
57 |
+
outputs=gr.Label(),
|
58 |
+
examples=examples,
|
59 |
+
title="Pneumonia X-Ray Classification",
|
60 |
+
description="Upload an X-ray image to classify it as normal or pneumonia.",
|
61 |
+
)
|
62 |
+
|
63 |
+
# Launch the app
|
64 |
+
if __name__ == "__main__":
|
65 |
+
iface.launch()
|
.history/app_20240617174712.py
ADDED
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import gradio as gr
|
3 |
+
from PIL import Image
|
4 |
+
import torch
|
5 |
+
import torchvision.transforms as transforms
|
6 |
+
from transformers import ViTForImageClassification, ViTImageProcessor
|
7 |
+
from datasets import load_dataset
|
8 |
+
|
9 |
+
# Model and processor configuration
|
10 |
+
model_name_or_path = "google/vit-base-patch16-224-in21k"
|
11 |
+
processor = ViTImageProcessor.from_pretrained(model_name_or_path)
|
12 |
+
|
13 |
+
# Load dataset (adjust dataset_path accordingly)
|
14 |
+
dataset_path = "pawlo2013/chest_xray"
|
15 |
+
train_dataset = load_dataset(dataset_path, split="train")
|
16 |
+
class_names = train_dataset.features["label"].names
|
17 |
+
|
18 |
+
# Load ViT model
|
19 |
+
model = ViTForImageClassification.from_pretrained(
|
20 |
+
"./models",
|
21 |
+
num_labels=len(class_names),
|
22 |
+
id2label={str(i): label for i, label in enumerate(class_names)},
|
23 |
+
label2id={label: i for i, label in enumerate(class_names)},
|
24 |
+
)
|
25 |
+
|
26 |
+
# Set model to evaluation mode
|
27 |
+
model.eval()
|
28 |
+
|
29 |
+
# Define transformation for incoming images
|
30 |
+
|
31 |
+
|
32 |
+
def classify_image(img):
|
33 |
+
# Dummy classification function, replace with your model inference
|
34 |
+
|
35 |
+
processed_input = processor(images=img, return_tensors="pt")
|
36 |
+
outputs = model(**processed_input)
|
37 |
+
|
38 |
+
return "Classified"
|
39 |
+
|
40 |
+
|
41 |
+
# Function to load examples from a folder
|
42 |
+
def load_examples_from_folder(folder_path):
|
43 |
+
examples = []
|
44 |
+
for file in os.listdir(folder_path):
|
45 |
+
if file.endswith((".png", ".jpg", ".jpeg")):
|
46 |
+
examples.append(os.path.join(folder_path, file))
|
47 |
+
return examples
|
48 |
+
|
49 |
+
|
50 |
+
# Define the path to the examples folder
|
51 |
+
examples_folder = "./examples"
|
52 |
+
examples = load_examples_from_folder(examples_folder)
|
53 |
+
|
54 |
+
# Create the Gradio interface
|
55 |
+
iface = gr.Interface(
|
56 |
+
fn=classify_image,
|
57 |
+
inputs=gr.Image(type="filepath"),
|
58 |
+
outputs=gr.Label(),
|
59 |
+
examples=examples,
|
60 |
+
title="Pneumonia X-Ray Classification",
|
61 |
+
description="Upload an X-ray image to classify it as normal or pneumonia.",
|
62 |
+
)
|
63 |
+
|
64 |
+
# Launch the app
|
65 |
+
if __name__ == "__main__":
|
66 |
+
iface.launch()
|
.history/app_20240617174718.py
ADDED
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import gradio as gr
|
3 |
+
from PIL import Image
|
4 |
+
import torch
|
5 |
+
import torchvision.transforms as transforms
|
6 |
+
from transformers import ViTForImageClassification, ViTImageProcessor
|
7 |
+
from datasets import load_dataset
|
8 |
+
|
9 |
+
# Model and processor configuration
|
10 |
+
model_name_or_path = "google/vit-base-patch16-224-in21k"
|
11 |
+
processor = ViTImageProcessor.from_pretrained(model_name_or_path)
|
12 |
+
|
13 |
+
# Load dataset (adjust dataset_path accordingly)
|
14 |
+
dataset_path = "pawlo2013/chest_xray"
|
15 |
+
train_dataset = load_dataset(dataset_path, split="train")
|
16 |
+
class_names = train_dataset.features["label"].names
|
17 |
+
|
18 |
+
# Load ViT model
|
19 |
+
model = ViTForImageClassification.from_pretrained(
|
20 |
+
"./models",
|
21 |
+
num_labels=len(class_names),
|
22 |
+
id2label={str(i): label for i, label in enumerate(class_names)},
|
23 |
+
label2id={label: i for i, label in enumerate(class_names)},
|
24 |
+
)
|
25 |
+
|
26 |
+
# Set model to evaluation mode
|
27 |
+
model.eval()
|
28 |
+
|
29 |
+
# Define transformation for incoming images
|
30 |
+
|
31 |
+
|
32 |
+
def classify_image(img):
|
33 |
+
# Dummy classification function, replace with your model inference
|
34 |
+
|
35 |
+
processed_input = processor(images=img, return_tensors="pt")
|
36 |
+
outputs = model(**processed_input)
|
37 |
+
logits = outputs.logits
|
38 |
+
predicted_class_idx = torch.argmax(logits).item()
|
39 |
+
|
40 |
+
return "Classified"
|
41 |
+
|
42 |
+
|
43 |
+
# Function to load examples from a folder
|
44 |
+
def load_examples_from_folder(folder_path):
|
45 |
+
examples = []
|
46 |
+
for file in os.listdir(folder_path):
|
47 |
+
if file.endswith((".png", ".jpg", ".jpeg")):
|
48 |
+
examples.append(os.path.join(folder_path, file))
|
49 |
+
return examples
|
50 |
+
|
51 |
+
|
52 |
+
# Define the path to the examples folder
|
53 |
+
examples_folder = "./examples"
|
54 |
+
examples = load_examples_from_folder(examples_folder)
|
55 |
+
|
56 |
+
# Create the Gradio interface
|
57 |
+
iface = gr.Interface(
|
58 |
+
fn=classify_image,
|
59 |
+
inputs=gr.Image(type="filepath"),
|
60 |
+
outputs=gr.Label(),
|
61 |
+
examples=examples,
|
62 |
+
title="Pneumonia X-Ray Classification",
|
63 |
+
description="Upload an X-ray image to classify it as normal or pneumonia.",
|
64 |
+
)
|
65 |
+
|
66 |
+
# Launch the app
|
67 |
+
if __name__ == "__main__":
|
68 |
+
iface.launch()
|
.history/app_20240617174723.py
ADDED
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import gradio as gr
|
3 |
+
from PIL import Image
|
4 |
+
import torch
|
5 |
+
import torchvision.transforms as transforms
|
6 |
+
from transformers import ViTForImageClassification, ViTImageProcessor
|
7 |
+
from datasets import load_dataset
|
8 |
+
|
9 |
+
# Model and processor configuration
|
10 |
+
model_name_or_path = "google/vit-base-patch16-224-in21k"
|
11 |
+
processor = ViTImageProcessor.from_pretrained(model_name_or_path)
|
12 |
+
|
13 |
+
# Load dataset (adjust dataset_path accordingly)
|
14 |
+
dataset_path = "pawlo2013/chest_xray"
|
15 |
+
train_dataset = load_dataset(dataset_path, split="train")
|
16 |
+
class_names = train_dataset.features["label"].names
|
17 |
+
|
18 |
+
# Load ViT model
|
19 |
+
model = ViTForImageClassification.from_pretrained(
|
20 |
+
"./models",
|
21 |
+
num_labels=len(class_names),
|
22 |
+
id2label={str(i): label for i, label in enumerate(class_names)},
|
23 |
+
label2id={label: i for i, label in enumerate(class_names)},
|
24 |
+
)
|
25 |
+
|
26 |
+
# Set model to evaluation mode
|
27 |
+
model.eval()
|
28 |
+
|
29 |
+
# Define transformation for incoming images
|
30 |
+
|
31 |
+
|
32 |
+
def classify_image(img):
|
33 |
+
# Dummy classification function, replace with your model inference
|
34 |
+
|
35 |
+
processed_input = processor(images=img, return_tensors="pt")
|
36 |
+
with torch.no_grad():
|
37 |
+
outputs = model(**processed_input)
|
38 |
+
logits = outputs.logits
|
39 |
+
predicted_class_idx = torch.argmax(logits).item()
|
40 |
+
|
41 |
+
return "Classified"
|
42 |
+
|
43 |
+
|
44 |
+
# Function to load examples from a folder
|
45 |
+
def load_examples_from_folder(folder_path):
|
46 |
+
examples = []
|
47 |
+
for file in os.listdir(folder_path):
|
48 |
+
if file.endswith((".png", ".jpg", ".jpeg")):
|
49 |
+
examples.append(os.path.join(folder_path, file))
|
50 |
+
return examples
|
51 |
+
|
52 |
+
|
53 |
+
# Define the path to the examples folder
|
54 |
+
examples_folder = "./examples"
|
55 |
+
examples = load_examples_from_folder(examples_folder)
|
56 |
+
|
57 |
+
# Create the Gradio interface
|
58 |
+
iface = gr.Interface(
|
59 |
+
fn=classify_image,
|
60 |
+
inputs=gr.Image(type="filepath"),
|
61 |
+
outputs=gr.Label(),
|
62 |
+
examples=examples,
|
63 |
+
title="Pneumonia X-Ray Classification",
|
64 |
+
description="Upload an X-ray image to classify it as normal or pneumonia.",
|
65 |
+
)
|
66 |
+
|
67 |
+
# Launch the app
|
68 |
+
if __name__ == "__main__":
|
69 |
+
iface.launch()
|
.history/app_20240617174727.py
ADDED
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import gradio as gr
|
3 |
+
from PIL import Image
|
4 |
+
import torch
|
5 |
+
import torchvision.transforms as transforms
|
6 |
+
from transformers import ViTForImageClassification, ViTImageProcessor
|
7 |
+
from datasets import load_dataset
|
8 |
+
|
9 |
+
# Model and processor configuration
|
10 |
+
model_name_or_path = "google/vit-base-patch16-224-in21k"
|
11 |
+
processor = ViTImageProcessor.from_pretrained(model_name_or_path)
|
12 |
+
|
13 |
+
# Load dataset (adjust dataset_path accordingly)
|
14 |
+
dataset_path = "pawlo2013/chest_xray"
|
15 |
+
train_dataset = load_dataset(dataset_path, split="train")
|
16 |
+
class_names = train_dataset.features["label"].names
|
17 |
+
|
18 |
+
# Load ViT model
|
19 |
+
model = ViTForImageClassification.from_pretrained(
|
20 |
+
"./models",
|
21 |
+
num_labels=len(class_names),
|
22 |
+
id2label={str(i): label for i, label in enumerate(class_names)},
|
23 |
+
label2id={label: i for i, label in enumerate(class_names)},
|
24 |
+
)
|
25 |
+
|
26 |
+
# Set model to evaluation mode
|
27 |
+
model.eval()
|
28 |
+
|
29 |
+
# Define transformation for incoming images
|
30 |
+
|
31 |
+
|
32 |
+
def classify_image(img):
|
33 |
+
# Dummy classification function, replace with your model inference
|
34 |
+
|
35 |
+
processed_input = processor(images=img, return_tensors="pt")
|
36 |
+
with torch.no_grad():
|
37 |
+
outputs = model(**processed_input)
|
38 |
+
logits = outputs.logits
|
39 |
+
predicted_class_idx = torch.argmax(logits).item()
|
40 |
+
predicted_class = class_names[predicted_class_idx]
|
41 |
+
|
42 |
+
return "Classified"
|
43 |
+
|
44 |
+
|
45 |
+
# Function to load examples from a folder
|
46 |
+
def load_examples_from_folder(folder_path):
|
47 |
+
examples = []
|
48 |
+
for file in os.listdir(folder_path):
|
49 |
+
if file.endswith((".png", ".jpg", ".jpeg")):
|
50 |
+
examples.append(os.path.join(folder_path, file))
|
51 |
+
return examples
|
52 |
+
|
53 |
+
|
54 |
+
# Define the path to the examples folder
|
55 |
+
examples_folder = "./examples"
|
56 |
+
examples = load_examples_from_folder(examples_folder)
|
57 |
+
|
58 |
+
# Create the Gradio interface
|
59 |
+
iface = gr.Interface(
|
60 |
+
fn=classify_image,
|
61 |
+
inputs=gr.Image(type="filepath"),
|
62 |
+
outputs=gr.Label(),
|
63 |
+
examples=examples,
|
64 |
+
title="Pneumonia X-Ray Classification",
|
65 |
+
description="Upload an X-ray image to classify it as normal or pneumonia.",
|
66 |
+
)
|
67 |
+
|
68 |
+
# Launch the app
|
69 |
+
if __name__ == "__main__":
|
70 |
+
iface.launch()
|
.history/app_20240617174736.py
ADDED
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import gradio as gr
|
3 |
+
from PIL import Image
|
4 |
+
import torch
|
5 |
+
import torchvision.transforms as transforms
|
6 |
+
from transformers import ViTForImageClassification, ViTImageProcessor
|
7 |
+
from datasets import load_dataset
|
8 |
+
|
9 |
+
# Model and processor configuration
|
10 |
+
model_name_or_path = "google/vit-base-patch16-224-in21k"
|
11 |
+
processor = ViTImageProcessor.from_pretrained(model_name_or_path)
|
12 |
+
|
13 |
+
# Load dataset (adjust dataset_path accordingly)
|
14 |
+
dataset_path = "pawlo2013/chest_xray"
|
15 |
+
train_dataset = load_dataset(dataset_path, split="train")
|
16 |
+
class_names = train_dataset.features["label"].names
|
17 |
+
|
18 |
+
# Load ViT model
|
19 |
+
model = ViTForImageClassification.from_pretrained(
|
20 |
+
"./models",
|
21 |
+
num_labels=len(class_names),
|
22 |
+
id2label={str(i): label for i, label in enumerate(class_names)},
|
23 |
+
label2id={label: i for i, label in enumerate(class_names)},
|
24 |
+
)
|
25 |
+
|
26 |
+
# Set model to evaluation mode
|
27 |
+
model.eval()
|
28 |
+
|
29 |
+
# Define transformation for incoming images
|
30 |
+
|
31 |
+
|
32 |
+
def classify_image(img):
|
33 |
+
# Dummy classification function, replace with your model inference
|
34 |
+
|
35 |
+
processed_input = processor(images=img, return_tensors="pt")
|
36 |
+
with torch.no_grad():
|
37 |
+
outputs = model(**processed_input)
|
38 |
+
logits = outputs.logits
|
39 |
+
predicted_class_idx = torch.argmax(logits).item()
|
40 |
+
predicted_class = class_names[predicted_class_idx]
|
41 |
+
return predicted_class
|
42 |
+
|
43 |
+
|
44 |
+
# Function to load examples from a folder
|
45 |
+
def load_examples_from_folder(folder_path):
|
46 |
+
examples = []
|
47 |
+
for file in os.listdir(folder_path):
|
48 |
+
if file.endswith((".png", ".jpg", ".jpeg")):
|
49 |
+
examples.append(os.path.join(folder_path, file))
|
50 |
+
return examples
|
51 |
+
|
52 |
+
|
53 |
+
# Define the path to the examples folder
|
54 |
+
examples_folder = "./examples"
|
55 |
+
examples = load_examples_from_folder(examples_folder)
|
56 |
+
|
57 |
+
# Create the Gradio interface
|
58 |
+
iface = gr.Interface(
|
59 |
+
fn=classify_image,
|
60 |
+
inputs=gr.Image(type="filepath"),
|
61 |
+
outputs=gr.Label(),
|
62 |
+
examples=examples,
|
63 |
+
title="Pneumonia X-Ray Classification",
|
64 |
+
description="Upload an X-ray image to classify it as normal or pneumonia.",
|
65 |
+
)
|
66 |
+
|
67 |
+
# Launch the app
|
68 |
+
if __name__ == "__main__":
|
69 |
+
iface.launch()
|
.history/app_20240617175003.py
ADDED
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import gradio as gr
|
3 |
+
from PIL import Image
|
4 |
+
import torch
|
5 |
+
import torchvision.transforms as transforms
|
6 |
+
from transformers import ViTForImageClassification, ViTImageProcessor
|
7 |
+
from datasets import load_dataset
|
8 |
+
|
9 |
+
# Model and processor configuration
|
10 |
+
model_name_or_path = "google/vit-base-patch16-224-in21k"
|
11 |
+
processor = ViTImageProcessor.from_pretrained(model_name_or_path)
|
12 |
+
|
13 |
+
# Load dataset (adjust dataset_path accordingly)
|
14 |
+
dataset_path = "pawlo2013/chest_xray"
|
15 |
+
train_dataset = load_dataset(dataset_path, split="train")
|
16 |
+
class_names = train_dataset.features["label"].names
|
17 |
+
|
18 |
+
# Load ViT model
|
19 |
+
model = ViTForImageClassification.from_pretrained(
|
20 |
+
"./models",
|
21 |
+
num_labels=len(class_names),
|
22 |
+
id2label={str(i): label for i, label in enumerate(class_names)},
|
23 |
+
label2id={label: i for i, label in enumerate(class_names)},
|
24 |
+
)
|
25 |
+
|
26 |
+
# Set model to evaluation mode
|
27 |
+
model.eval()
|
28 |
+
|
29 |
+
# Define transformation for incoming images
|
30 |
+
|
31 |
+
|
32 |
+
def classify_image(img):
|
33 |
+
# Dummy classification function, replace with your model inference
|
34 |
+
|
35 |
+
img = Image.open(img)
|
36 |
+
|
37 |
+
processed_input = processor(images=img, return_tensors="pt")
|
38 |
+
with torch.no_grad():
|
39 |
+
outputs = model(**processed_input)
|
40 |
+
logits = outputs.logits
|
41 |
+
predicted_class_idx = torch.argmax(logits).item()
|
42 |
+
predicted_class = class_names[predicted_class_idx]
|
43 |
+
return predicted_class
|
44 |
+
|
45 |
+
|
46 |
+
# Function to load examples from a folder
|
47 |
+
def load_examples_from_folder(folder_path):
|
48 |
+
examples = []
|
49 |
+
for file in os.listdir(folder_path):
|
50 |
+
if file.endswith((".png", ".jpg", ".jpeg")):
|
51 |
+
examples.append(os.path.join(folder_path, file))
|
52 |
+
return examples
|
53 |
+
|
54 |
+
|
55 |
+
# Define the path to the examples folder
|
56 |
+
examples_folder = "./examples"
|
57 |
+
examples = load_examples_from_folder(examples_folder)
|
58 |
+
|
59 |
+
# Create the Gradio interface
|
60 |
+
iface = gr.Interface(
|
61 |
+
fn=classify_image,
|
62 |
+
inputs=gr.Image(type="filepath"),
|
63 |
+
outputs=gr.Label(),
|
64 |
+
examples=examples,
|
65 |
+
title="Pneumonia X-Ray Classification",
|
66 |
+
description="Upload an X-ray image to classify it as normal or pneumonia.",
|
67 |
+
)
|
68 |
+
|
69 |
+
# Launch the app
|
70 |
+
if __name__ == "__main__":
|
71 |
+
iface.launch()
|
.history/app_20240617175116.py
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import gradio as gr
|
3 |
+
from PIL import Image
|
4 |
+
import torch
|
5 |
+
from transformers import ViTForImageClassification, ViTImageProcessor
|
6 |
+
from datasets import load_dataset
|
7 |
+
|
8 |
+
# Model and processor configuration
|
9 |
+
model_name_or_path = "google/vit-base-patch16-224-in21k"
|
10 |
+
processor = ViTImageProcessor.from_pretrained(model_name_or_path)
|
11 |
+
|
12 |
+
# Load dataset (adjust dataset_path accordingly)
|
13 |
+
dataset_path = "pawlo2013/chest_xray"
|
14 |
+
train_dataset = load_dataset(dataset_path, split="train")
|
15 |
+
class_names = train_dataset.features["label"].names
|
16 |
+
|
17 |
+
# Load ViT model
|
18 |
+
model = ViTForImageClassification.from_pretrained(
|
19 |
+
"./models",
|
20 |
+
num_labels=len(class_names),
|
21 |
+
id2label={str(i): label for i, label in enumerate(class_names)},
|
22 |
+
label2id={label: i for i, label in enumerate(class_names)},
|
23 |
+
)
|
24 |
+
|
25 |
+
# Set model to evaluation mode
|
26 |
+
model.eval()
|
27 |
+
|
28 |
+
|
29 |
+
# Define the classification function
|
30 |
+
def classify_image(img_path):
|
31 |
+
img = Image.open(img_path)
|
32 |
+
processed_input = processor(images=img, return_tensors="pt")
|
33 |
+
with torch.no_grad():
|
34 |
+
outputs = model(**processed_input)
|
35 |
+
logits = outputs.logits
|
36 |
+
probabilities = torch.softmax(logits, dim=1)[0].tolist()
|
37 |
+
|
38 |
+
result = {class_name: prob for class_name, prob in zip(class_names, probabilities)}
|
39 |
+
return result
|
40 |
+
|
41 |
+
|
42 |
+
# Function to load examples from a folder
|
43 |
+
def load_examples_from_folder(folder_path):
|
44 |
+
examples = []
|
45 |
+
for file in os.listdir(folder_path):
|
46 |
+
if file.endswith((".png", ".jpg", ".jpeg")):
|
47 |
+
examples.append(os.path.join(folder_path, file))
|
48 |
+
return examples
|
49 |
+
|
50 |
+
|
51 |
+
# Define the path to the examples folder
|
52 |
+
examples_folder = "./examples"
|
53 |
+
examples = load_examples_from_folder(examples_folder)
|
54 |
+
|
55 |
+
# Create the Gradio interface
|
56 |
+
iface = gr.Interface(
|
57 |
+
fn=classify_image,
|
58 |
+
inputs=gr.Image(type="filepath"),
|
59 |
+
outputs=gr.BarChart(),
|
60 |
+
examples=examples,
|
61 |
+
title="Pneumonia X-Ray Classification",
|
62 |
+
description="Upload an X-ray image to classify it as normal or pneumonia.",
|
63 |
+
)
|
64 |
+
|
65 |
+
# Launch the app
|
66 |
+
if __name__ == "__main__":
|
67 |
+
iface.launch()
|
.history/app_20240617175159.py
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import gradio as gr
|
3 |
+
from PIL import Image
|
4 |
+
import torch
|
5 |
+
from transformers import ViTForImageClassification, ViTImageProcessor
|
6 |
+
from datasets import load_dataset
|
7 |
+
|
8 |
+
# Model and processor configuration
|
9 |
+
model_name_or_path = "google/vit-base-patch16-224-in21k"
|
10 |
+
processor = ViTImageProcessor.from_pretrained(model_name_or_path)
|
11 |
+
|
12 |
+
# Load dataset (adjust dataset_path accordingly)
|
13 |
+
dataset_path = "pawlo2013/chest_xray"
|
14 |
+
train_dataset = load_dataset(dataset_path, split="train")
|
15 |
+
class_names = train_dataset.features["label"].names
|
16 |
+
|
17 |
+
# Load ViT model
|
18 |
+
model = ViTForImageClassification.from_pretrained(
|
19 |
+
"./models",
|
20 |
+
num_labels=len(class_names),
|
21 |
+
id2label={str(i): label for i, label in enumerate(class_names)},
|
22 |
+
label2id={label: i for i, label in enumerate(class_names)},
|
23 |
+
)
|
24 |
+
|
25 |
+
# Set model to evaluation mode
|
26 |
+
model.eval()
|
27 |
+
|
28 |
+
|
29 |
+
# Define the classification function
|
30 |
+
def classify_image(img_path):
|
31 |
+
img = Image.open(img_path)
|
32 |
+
processed_input = processor(images=img, return_tensors="pt")
|
33 |
+
with torch.no_grad():
|
34 |
+
outputs = model(**processed_input)
|
35 |
+
logits = outputs.logits
|
36 |
+
probabilities = torch.softmax(logits, dim=1)[0].tolist()
|
37 |
+
|
38 |
+
result = {class_name: prob for class_name, prob in zip(class_names, probabilities)}
|
39 |
+
return result
|
40 |
+
|
41 |
+
|
42 |
+
# Function to load examples from a folder
|
43 |
+
def load_examples_from_folder(folder_path):
|
44 |
+
examples = []
|
45 |
+
for file in os.listdir(folder_path):
|
46 |
+
if file.endswith((".png", ".jpg", ".jpeg")):
|
47 |
+
examples.append(os.path.join(folder_path, file))
|
48 |
+
return examples
|
49 |
+
|
50 |
+
|
51 |
+
# Define the path to the examples folder
|
52 |
+
examples_folder = "./examples"
|
53 |
+
examples = load_examples_from_folder(examples_folder)
|
54 |
+
|
55 |
+
# Create the Gradio interface
|
56 |
+
iface = gr.Interface(
|
57 |
+
fn=classify_image,
|
58 |
+
inputs=gr.Image(type="filepath"),
|
59 |
+
outputs=gr.BarPlot(),
|
60 |
+
examples=examples,
|
61 |
+
title="Pneumonia X-Ray Classification",
|
62 |
+
description="Upload an X-ray image to classify it as normal or pneumonia.",
|
63 |
+
)
|
64 |
+
|
65 |
+
# Launch the app
|
66 |
+
if __name__ == "__main__":
|
67 |
+
iface.launch()
|
.history/app_20240617175308.py
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import gradio as gr
|
3 |
+
from PIL import Image
|
4 |
+
import torch
|
5 |
+
from transformers import ViTForImageClassification, ViTImageProcessor
|
6 |
+
from datasets import load_dataset
|
7 |
+
|
8 |
+
# Model and processor configuration
|
9 |
+
model_name_or_path = "google/vit-base-patch16-224-in21k"
|
10 |
+
processor = ViTImageProcessor.from_pretrained(model_name_or_path)
|
11 |
+
|
12 |
+
# Load dataset (adjust dataset_path accordingly)
|
13 |
+
dataset_path = "pawlo2013/chest_xray"
|
14 |
+
train_dataset = load_dataset(dataset_path, split="train")
|
15 |
+
class_names = train_dataset.features["label"].names
|
16 |
+
|
17 |
+
# Load ViT model
|
18 |
+
model = ViTForImageClassification.from_pretrained(
|
19 |
+
"./models",
|
20 |
+
num_labels=len(class_names),
|
21 |
+
id2label={str(i): label for i, label in enumerate(class_names)},
|
22 |
+
label2id={label: i for i, label in enumerate(class_names)},
|
23 |
+
)
|
24 |
+
|
25 |
+
# Set model to evaluation mode
|
26 |
+
model.eval()
|
27 |
+
|
28 |
+
|
29 |
+
# Define the classification function
|
30 |
+
def classify_image(img_path):
|
31 |
+
img = Image.open(img_path)
|
32 |
+
processed_input = processor(images=img, return_tensors="pt")
|
33 |
+
with torch.no_grad():
|
34 |
+
outputs = model(**processed_input)
|
35 |
+
logits = outputs.logits
|
36 |
+
probabilities = torch.softmax(logits, dim=1)[0].tolist()
|
37 |
+
|
38 |
+
result = {class_name: prob for class_name, prob in zip(class_names, probabilities)}
|
39 |
+
return result
|
40 |
+
|
41 |
+
|
42 |
+
# Function to load examples from a folder
|
43 |
+
def load_examples_from_folder(folder_path):
|
44 |
+
examples = []
|
45 |
+
for file in os.listdir(folder_path):
|
46 |
+
if file.endswith((".png", ".jpg", ".jpeg")):
|
47 |
+
examples.append(os.path.join(folder_path, file))
|
48 |
+
return examples
|
49 |
+
|
50 |
+
|
51 |
+
# Define the path to the examples folder
|
52 |
+
examples_folder = "./examples"
|
53 |
+
examples = load_examples_from_folder(examples_folder)
|
54 |
+
|
55 |
+
# Create the Gradio interface
|
56 |
+
iface = gr.Interface(
|
57 |
+
fn=classify_image,
|
58 |
+
inputs=gr.Image(type="filepath"),
|
59 |
+
outputs=gr.Label(),
|
60 |
+
examples=examples,
|
61 |
+
title="Pneumonia X-Ray Classification",
|
62 |
+
description="Upload an X-ray image to classify it as normal or pneumonia.",
|
63 |
+
)
|
64 |
+
|
65 |
+
# Launch the app
|
66 |
+
if __name__ == "__main__":
|
67 |
+
iface.launch()
|
.history/app_20240617175426.py
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import gradio as gr
|
3 |
+
from PIL import Image
|
4 |
+
import torch
|
5 |
+
from transformers import ViTForImageClassification, ViTImageProcessor
|
6 |
+
from datasets import load_dataset
|
7 |
+
|
8 |
+
# Model and processor configuration
|
9 |
+
model_name_or_path = "google/vit-base-patch16-224-in21k"
|
10 |
+
processor = ViTImageProcessor.from_pretrained(model_name_or_path)
|
11 |
+
|
12 |
+
# Load dataset (adjust dataset_path accordingly)
|
13 |
+
dataset_path = "pawlo2013/chest_xray"
|
14 |
+
train_dataset = load_dataset(dataset_path, split="train")
|
15 |
+
class_names = train_dataset.features["label"].names
|
16 |
+
|
17 |
+
# Load ViT model
|
18 |
+
model = ViTForImageClassification.from_pretrained(
|
19 |
+
"./models",
|
20 |
+
num_labels=len(class_names),
|
21 |
+
id2label={str(i): label for i, label in enumerate(class_names)},
|
22 |
+
label2id={label: i for i, label in enumerate(class_names)},
|
23 |
+
)
|
24 |
+
|
25 |
+
# Set model to evaluation mode
|
26 |
+
model.eval()
|
27 |
+
|
28 |
+
|
29 |
+
# Define the classification function
|
30 |
+
def classify_image(img_path):
|
31 |
+
img = Image.open(img_path)
|
32 |
+
processed_input = processor(images=img, return_tensors="pt")
|
33 |
+
with torch.no_grad():
|
34 |
+
outputs = model(**processed_input)
|
35 |
+
logits = outputs.logits
|
36 |
+
probabilities = torch.softmax(logits, dim=1)[0].tolist()
|
37 |
+
|
38 |
+
result = {class_name: prob for class_name, prob in zip(class_names, probabilities)}
|
39 |
+
return result
|
40 |
+
|
41 |
+
|
42 |
+
# Function to load examples from a folder
|
43 |
+
def load_examples_from_folder(folder_path):
|
44 |
+
examples = []
|
45 |
+
for file in os.listdir(folder_path):
|
46 |
+
if file.endswith((".png", ".jpg", ".jpeg")):
|
47 |
+
examples.append(os.path.join(folder_path, file))
|
48 |
+
return examples
|
49 |
+
|
50 |
+
|
51 |
+
# Define the path to the examples folder
|
52 |
+
examples_folder = "./examples"
|
53 |
+
examples = load_examples_from_folder(examples_folder)
|
54 |
+
|
55 |
+
# Create the Gradio interface
|
56 |
+
iface = gr.Interface(
|
57 |
+
fn=classify_image,
|
58 |
+
inputs=gr.Image(type="filepath"),
|
59 |
+
outputs=gr.Label(),
|
60 |
+
examples=examples,
|
61 |
+
title="Pneumonia X-Ray Classification",
|
62 |
+
description="Upload an X-ray image to classify it as normal or pneumonia.",
|
63 |
+
)
|
64 |
+
|
65 |
+
# Launch the app
|
66 |
+
if __name__ == "__main__":
|
67 |
+
iface.launch()
|
.history/app_20240617175718.py
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import gradio as gr
|
3 |
+
from PIL import Image
|
4 |
+
import torch
|
5 |
+
from transformers import ViTForImageClassification, ViTImageProcessor
|
6 |
+
from datasets import load_dataset
|
7 |
+
|
8 |
+
# Model and processor configuration
|
9 |
+
model_name_or_path = "google/vit-base-patch16-224-in21k"
|
10 |
+
processor = ViTImageProcessor.from_pretrained(model_name_or_path)
|
11 |
+
|
12 |
+
# Load dataset (adjust dataset_path accordingly)
|
13 |
+
dataset_path = "pawlo2013/chest_xray"
|
14 |
+
train_dataset = load_dataset(dataset_path, split="train")
|
15 |
+
class_names = train_dataset.features["label"].names
|
16 |
+
|
17 |
+
# Load ViT model
|
18 |
+
model = ViTForImageClassification.from_pretrained(
|
19 |
+
"./models",
|
20 |
+
num_labels=len(class_names),
|
21 |
+
id2label={str(i): label for i, label in enumerate(class_names)},
|
22 |
+
label2id={label: i for i, label in enumerate(class_names)},
|
23 |
+
)
|
24 |
+
|
25 |
+
# Set model to evaluation mode
|
26 |
+
model.eval()
|
27 |
+
|
28 |
+
|
29 |
+
# Define the classification function
|
30 |
+
def classify_image(img_path):
|
31 |
+
img = Image.open(img_path)
|
32 |
+
processed_input = processor(images=img, return_tensors="pt")
|
33 |
+
with torch.no_grad():
|
34 |
+
outputs = model(**processed_input)
|
35 |
+
logits = outputs.logits
|
36 |
+
probabilities = torch.softmax(logits, dim=1)[0].tolist()
|
37 |
+
|
38 |
+
result = {class_name: prob for class_name, prob in zip(class_names, probabilities)}
|
39 |
+
return result
|
40 |
+
|
41 |
+
|
42 |
+
# Function to load examples from a folder
|
43 |
+
def load_examples_from_folder(folder_path):
|
44 |
+
examples = []
|
45 |
+
for file in os.listdir(folder_path):
|
46 |
+
if file.endswith((".png", ".jpg", ".jpeg")):
|
47 |
+
examples.append(os.path.join(folder_path, file))
|
48 |
+
return examples
|
49 |
+
|
50 |
+
|
51 |
+
# Define the path to the examples folder
|
52 |
+
examples_folder = "./examples"
|
53 |
+
examples = load_examples_from_folder(examples_folder)
|
54 |
+
|
55 |
+
# Create the Gradio interface
|
56 |
+
iface = gr.Interface(
|
57 |
+
fn=classify_image,
|
58 |
+
inputs=gr.Image(type="filepath"),
|
59 |
+
outputs=[gr.Textbox(label="Filename"), gr.BarChart(label="Class Probabilities")],
|
60 |
+
examples=examples,
|
61 |
+
title="Pneumonia X-Ray Classification",
|
62 |
+
description="Upload an X-ray image to classify it as normal or pneumonia.",
|
63 |
+
)
|
64 |
+
|
65 |
+
# Launch the app
|
66 |
+
if __name__ == "__main__":
|
67 |
+
iface.launch()
|
.history/app_20240617175727.py
ADDED
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import gradio as gr
|
3 |
+
from PIL import Image
|
4 |
+
import torch
|
5 |
+
from transformers import ViTForImageClassification, ViTImageProcessor
|
6 |
+
from datasets import load_dataset
|
7 |
+
|
8 |
+
# Model and processor configuration
|
9 |
+
model_name_or_path = "google/vit-base-patch16-224-in21k"
|
10 |
+
processor = ViTImageProcessor.from_pretrained(model_name_or_path)
|
11 |
+
|
12 |
+
# Load dataset (adjust dataset_path accordingly)
|
13 |
+
dataset_path = "pawlo2013/chest_xray"
|
14 |
+
train_dataset = load_dataset(dataset_path, split="train")
|
15 |
+
class_names = train_dataset.features["label"].names
|
16 |
+
|
17 |
+
# Load ViT model
|
18 |
+
model = ViTForImageClassification.from_pretrained(
|
19 |
+
"./models",
|
20 |
+
num_labels=len(class_names),
|
21 |
+
id2label={str(i): label for i, label in enumerate(class_names)},
|
22 |
+
label2id={label: i for i, label in enumerate(class_names)},
|
23 |
+
)
|
24 |
+
|
25 |
+
# Set model to evaluation mode
|
26 |
+
model.eval()
|
27 |
+
|
28 |
+
|
29 |
+
# Define the classification function
|
30 |
+
def classify_image(img_path):
|
31 |
+
img = Image.open(img_path)
|
32 |
+
processed_input = processor(images=img, return_tensors="pt")
|
33 |
+
with torch.no_grad():
|
34 |
+
outputs = model(**processed_input)
|
35 |
+
logits = outputs.logits
|
36 |
+
probabilities = torch.softmax(logits, dim=1)[0].tolist()
|
37 |
+
|
38 |
+
result = {class_name: prob for class_name, prob in zip(class_names, probabilities)}
|
39 |
+
return result
|
40 |
+
|
41 |
+
|
42 |
+
def format_output(output):
|
43 |
+
return f"Filename: {output['filename']}", output["probabilities"]
|
44 |
+
|
45 |
+
|
46 |
+
# Function to load examples from a folder
|
47 |
+
def load_examples_from_folder(folder_path):
|
48 |
+
examples = []
|
49 |
+
for file in os.listdir(folder_path):
|
50 |
+
if file.endswith((".png", ".jpg", ".jpeg")):
|
51 |
+
examples.append(os.path.join(folder_path, file))
|
52 |
+
return examples
|
53 |
+
|
54 |
+
|
55 |
+
# Define the path to the examples folder
|
56 |
+
examples_folder = "./examples"
|
57 |
+
examples = load_examples_from_folder(examples_folder)
|
58 |
+
|
59 |
+
# Create the Gradio interface
|
60 |
+
iface = gr.Interface(
|
61 |
+
fn=classify_image,
|
62 |
+
inputs=gr.Image(type="filepath"),
|
63 |
+
outputs=[gr.Textbox(label="Filename"), gr.BarChart(label="Class Probabilities")],
|
64 |
+
examples=examples,
|
65 |
+
title="Pneumonia X-Ray Classification",
|
66 |
+
description="Upload an X-ray image to classify it as normal or pneumonia.",
|
67 |
+
)
|
68 |
+
|
69 |
+
# Launch the app
|
70 |
+
if __name__ == "__main__":
|
71 |
+
iface.launch()
|
.history/app_20240617175737.py
ADDED
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import gradio as gr
|
3 |
+
from PIL import Image
|
4 |
+
import torch
|
5 |
+
from transformers import ViTForImageClassification, ViTImageProcessor
|
6 |
+
from datasets import load_dataset
|
7 |
+
|
8 |
+
# Model and processor configuration
|
9 |
+
model_name_or_path = "google/vit-base-patch16-224-in21k"
|
10 |
+
processor = ViTImageProcessor.from_pretrained(model_name_or_path)
|
11 |
+
|
12 |
+
# Load dataset (adjust dataset_path accordingly)
|
13 |
+
dataset_path = "pawlo2013/chest_xray"
|
14 |
+
train_dataset = load_dataset(dataset_path, split="train")
|
15 |
+
class_names = train_dataset.features["label"].names
|
16 |
+
|
17 |
+
# Load ViT model
|
18 |
+
model = ViTForImageClassification.from_pretrained(
|
19 |
+
"./models",
|
20 |
+
num_labels=len(class_names),
|
21 |
+
id2label={str(i): label for i, label in enumerate(class_names)},
|
22 |
+
label2id={label: i for i, label in enumerate(class_names)},
|
23 |
+
)
|
24 |
+
|
25 |
+
# Set model to evaluation mode
|
26 |
+
model.eval()
|
27 |
+
|
28 |
+
|
29 |
+
# Define the classification function
|
30 |
+
def classify_image(img_path):
|
31 |
+
img = Image.open(img_path)
|
32 |
+
processed_input = processor(images=img, return_tensors="pt")
|
33 |
+
with torch.no_grad():
|
34 |
+
outputs = model(**processed_input)
|
35 |
+
logits = outputs.logits
|
36 |
+
probabilities = torch.softmax(logits, dim=1)[0].tolist()
|
37 |
+
|
38 |
+
result = {class_name: prob for class_name, prob in zip(class_names, probabilities)}
|
39 |
+
filename = os.path.basename(img_path)
|
40 |
+
return {"filename": filename, "probabilities": result}
|
41 |
+
|
42 |
+
|
43 |
+
def format_output(output):
|
44 |
+
return f"Filename: {output['filename']}", output["probabilities"]
|
45 |
+
|
46 |
+
|
47 |
+
# Function to load examples from a folder
|
48 |
+
def load_examples_from_folder(folder_path):
|
49 |
+
examples = []
|
50 |
+
for file in os.listdir(folder_path):
|
51 |
+
if file.endswith((".png", ".jpg", ".jpeg")):
|
52 |
+
examples.append(os.path.join(folder_path, file))
|
53 |
+
return examples
|
54 |
+
|
55 |
+
|
56 |
+
# Define the path to the examples folder
|
57 |
+
examples_folder = "./examples"
|
58 |
+
examples = load_examples_from_folder(examples_folder)
|
59 |
+
|
60 |
+
# Create the Gradio interface
|
61 |
+
iface = gr.Interface(
|
62 |
+
fn=classify_image,
|
63 |
+
inputs=gr.Image(type="filepath"),
|
64 |
+
outputs=[gr.Textbox(label="Filename"), gr.BarChart(label="Class Probabilities")],
|
65 |
+
examples=examples,
|
66 |
+
title="Pneumonia X-Ray Classification",
|
67 |
+
description="Upload an X-ray image to classify it as normal or pneumonia.",
|
68 |
+
)
|
69 |
+
|
70 |
+
# Launch the app
|
71 |
+
if __name__ == "__main__":
|
72 |
+
iface.launch()
|
.history/app_20240617175752.py
ADDED
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import gradio as gr
|
3 |
+
from PIL import Image
|
4 |
+
import torch
|
5 |
+
from transformers import ViTForImageClassification, ViTImageProcessor
|
6 |
+
from datasets import load_dataset
|
7 |
+
|
8 |
+
# Model and processor configuration
|
9 |
+
model_name_or_path = "google/vit-base-patch16-224-in21k"
|
10 |
+
processor = ViTImageProcessor.from_pretrained(model_name_or_path)
|
11 |
+
|
12 |
+
# Load dataset (adjust dataset_path accordingly)
|
13 |
+
dataset_path = "pawlo2013/chest_xray"
|
14 |
+
train_dataset = load_dataset(dataset_path, split="train")
|
15 |
+
class_names = train_dataset.features["label"].names
|
16 |
+
|
17 |
+
# Load ViT model
|
18 |
+
model = ViTForImageClassification.from_pretrained(
|
19 |
+
"./models",
|
20 |
+
num_labels=len(class_names),
|
21 |
+
id2label={str(i): label for i, label in enumerate(class_names)},
|
22 |
+
label2id={label: i for i, label in enumerate(class_names)},
|
23 |
+
)
|
24 |
+
|
25 |
+
# Set model to evaluation mode
|
26 |
+
model.eval()
|
27 |
+
|
28 |
+
|
29 |
+
# Define the classification function
|
30 |
+
def classify_image(img_path):
|
31 |
+
img = Image.open(img_path)
|
32 |
+
processed_input = processor(images=img, return_tensors="pt")
|
33 |
+
with torch.no_grad():
|
34 |
+
outputs = model(**processed_input)
|
35 |
+
logits = outputs.logits
|
36 |
+
probabilities = torch.softmax(logits, dim=1)[0].tolist()
|
37 |
+
|
38 |
+
result = {class_name: prob for class_name, prob in zip(class_names, probabilities)}
|
39 |
+
filename = os.path.basename(img_path)
|
40 |
+
return {"filename": filename, "probabilities": result}
|
41 |
+
|
42 |
+
|
43 |
+
def format_output(output):
|
44 |
+
return f"Filename: {output['filename']}", output["probabilities"]
|
45 |
+
|
46 |
+
|
47 |
+
# Function to load examples from a folder
|
48 |
+
def load_examples_from_folder(folder_path):
|
49 |
+
examples = []
|
50 |
+
for file in os.listdir(folder_path):
|
51 |
+
if file.endswith((".png", ".jpg", ".jpeg")):
|
52 |
+
examples.append(os.path.join(folder_path, file))
|
53 |
+
return examples
|
54 |
+
|
55 |
+
|
56 |
+
# Define the path to the examples folder
|
57 |
+
examples_folder = "./examples"
|
58 |
+
examples = load_examples_from_folder(examples_folder)
|
59 |
+
|
60 |
+
# Create the Gradio interface
|
61 |
+
iface = gr.Interface(
|
62 |
+
fn=lambda img: format_output(classify_image(img)),
|
63 |
+
inputs=gr.Image(type="filepath"),
|
64 |
+
outputs=[gr.Textbox(label="Filename"), gr.BarChart(label="Class Probabilities")],
|
65 |
+
examples=examples,
|
66 |
+
title="Pneumonia X-Ray Classification",
|
67 |
+
description="Upload an X-ray image to classify it as normal or pneumonia.",
|
68 |
+
)
|
69 |
+
|
70 |
+
# Launch the app
|
71 |
+
if __name__ == "__main__":
|
72 |
+
iface.launch()
|
.history/app_20240617175811.py
ADDED
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import gradio as gr
|
3 |
+
from PIL import Image
|
4 |
+
import torch
|
5 |
+
from transformers import ViTForImageClassification, ViTImageProcessor
|
6 |
+
from datasets import load_dataset
|
7 |
+
|
8 |
+
# Model and processor configuration
|
9 |
+
model_name_or_path = "google/vit-base-patch16-224-in21k"
|
10 |
+
processor = ViTImageProcessor.from_pretrained(model_name_or_path)
|
11 |
+
|
12 |
+
# Load dataset (adjust dataset_path accordingly)
|
13 |
+
dataset_path = "pawlo2013/chest_xray"
|
14 |
+
train_dataset = load_dataset(dataset_path, split="train")
|
15 |
+
class_names = train_dataset.features["label"].names
|
16 |
+
|
17 |
+
# Load ViT model
|
18 |
+
model = ViTForImageClassification.from_pretrained(
|
19 |
+
"./models",
|
20 |
+
num_labels=len(class_names),
|
21 |
+
id2label={str(i): label for i, label in enumerate(class_names)},
|
22 |
+
label2id={label: i for i, label in enumerate(class_names)},
|
23 |
+
)
|
24 |
+
|
25 |
+
# Set model to evaluation mode
|
26 |
+
model.eval()
|
27 |
+
|
28 |
+
|
29 |
+
# Define the classification function
|
30 |
+
def classify_image(img_path):
|
31 |
+
img = Image.open(img_path)
|
32 |
+
processed_input = processor(images=img, return_tensors="pt")
|
33 |
+
with torch.no_grad():
|
34 |
+
outputs = model(**processed_input)
|
35 |
+
logits = outputs.logits
|
36 |
+
probabilities = torch.softmax(logits, dim=1)[0].tolist()
|
37 |
+
|
38 |
+
result = {class_name: prob for class_name, prob in zip(class_names, probabilities)}
|
39 |
+
filename = os.path.basename(img_path)
|
40 |
+
return {"filename": filename, "probabilities": result}
|
41 |
+
|
42 |
+
|
43 |
+
def format_output(output):
|
44 |
+
return f"Filename: {output['filename']}", output["probabilities"]
|
45 |
+
|
46 |
+
|
47 |
+
# Function to load examples from a folder
|
48 |
+
def load_examples_from_folder(folder_path):
|
49 |
+
examples = []
|
50 |
+
for file in os.listdir(folder_path):
|
51 |
+
if file.endswith((".png", ".jpg", ".jpeg")):
|
52 |
+
examples.append(os.path.join(folder_path, file))
|
53 |
+
return examples
|
54 |
+
|
55 |
+
|
56 |
+
# Define the path to the examples folder
|
57 |
+
examples_folder = "./examples"
|
58 |
+
examples = load_examples_from_folder(examples_folder)
|
59 |
+
|
60 |
+
# Create the Gradio interface
|
61 |
+
iface = gr.Interface(
|
62 |
+
fn=lambda img: format_output(classify_image(img)),
|
63 |
+
inputs=gr.Image(type="filepath"),
|
64 |
+
outputs=[gr.Textbox(label="Filename"), gr.Label(label="Class Probabilities")],
|
65 |
+
examples=examples,
|
66 |
+
title="Pneumonia X-Ray Classification",
|
67 |
+
description="Upload an X-ray image to classify it as normal or pneumonia.",
|
68 |
+
)
|
69 |
+
|
70 |
+
# Launch the app
|
71 |
+
if __name__ == "__main__":
|
72 |
+
iface.launch()
|
.history/app_20240617175818.py
ADDED
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import gradio as gr
|
3 |
+
from PIL import Image
|
4 |
+
import torch
|
5 |
+
from transformers import ViTForImageClassification, ViTImageProcessor
|
6 |
+
from datasets import load_dataset
|
7 |
+
|
8 |
+
# Model and processor configuration
|
9 |
+
model_name_or_path = "google/vit-base-patch16-224-in21k"
|
10 |
+
processor = ViTImageProcessor.from_pretrained(model_name_or_path)
|
11 |
+
|
12 |
+
# Load dataset (adjust dataset_path accordingly)
|
13 |
+
dataset_path = "pawlo2013/chest_xray"
|
14 |
+
train_dataset = load_dataset(dataset_path, split="train")
|
15 |
+
class_names = train_dataset.features["label"].names
|
16 |
+
|
17 |
+
# Load ViT model
|
18 |
+
model = ViTForImageClassification.from_pretrained(
|
19 |
+
"./models",
|
20 |
+
num_labels=len(class_names),
|
21 |
+
id2label={str(i): label for i, label in enumerate(class_names)},
|
22 |
+
label2id={label: i for i, label in enumerate(class_names)},
|
23 |
+
)
|
24 |
+
|
25 |
+
# Set model to evaluation mode
|
26 |
+
model.eval()
|
27 |
+
|
28 |
+
|
29 |
+
# Define the classification function
|
30 |
+
def classify_image(img_path):
|
31 |
+
img = Image.open(img_path)
|
32 |
+
processed_input = processor(images=img, return_tensors="pt")
|
33 |
+
with torch.no_grad():
|
34 |
+
outputs = model(**processed_input)
|
35 |
+
logits = outputs.logits
|
36 |
+
probabilities = torch.softmax(logits, dim=1)[0].tolist()
|
37 |
+
|
38 |
+
result = {class_name: prob for class_name, prob in zip(class_names, probabilities)}
|
39 |
+
filename = os.path.basename(img_path)
|
40 |
+
return {"filename": filename, "probabilities": result}
|
41 |
+
|
42 |
+
|
43 |
+
def format_output(output):
|
44 |
+
return f"Filename: {output['filename']}", output["probabilities"]
|
45 |
+
|
46 |
+
|
47 |
+
# Function to load examples from a folder
|
48 |
+
def load_examples_from_folder(folder_path):
|
49 |
+
examples = []
|
50 |
+
for file in os.listdir(folder_path):
|
51 |
+
if file.endswith((".png", ".jpg", ".jpeg")):
|
52 |
+
examples.append(os.path.join(folder_path, file))
|
53 |
+
return examples
|
54 |
+
|
55 |
+
|
56 |
+
# Define the path to the examples folder
|
57 |
+
examples_folder = "./examples"
|
58 |
+
examples = load_examples_from_folder(examples_folder)
|
59 |
+
|
60 |
+
# Create the Gradio interface
|
61 |
+
iface = gr.Interface(
|
62 |
+
fn=lambda img: format_output(classify_image(img)),
|
63 |
+
inputs=gr.Image(type="filepath"),
|
64 |
+
outputs=[gr.Textbox(label="Filename"), gr.Label()],
|
65 |
+
examples=examples,
|
66 |
+
title="Pneumonia X-Ray Classification",
|
67 |
+
description="Upload an X-ray image to classify it as normal or pneumonia.",
|
68 |
+
)
|
69 |
+
|
70 |
+
# Launch the app
|
71 |
+
if __name__ == "__main__":
|
72 |
+
iface.launch()
|
.history/app_20240617175857.py
ADDED
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import gradio as gr
|
3 |
+
from PIL import Image
|
4 |
+
import torch
|
5 |
+
from transformers import ViTForImageClassification, ViTImageProcessor
|
6 |
+
from datasets import load_dataset
|
7 |
+
|
8 |
+
# Model and processor configuration
|
9 |
+
model_name_or_path = "google/vit-base-patch16-224-in21k"
|
10 |
+
processor = ViTImageProcessor.from_pretrained(model_name_or_path)
|
11 |
+
|
12 |
+
# Load dataset (adjust dataset_path accordingly)
|
13 |
+
dataset_path = "pawlo2013/chest_xray"
|
14 |
+
train_dataset = load_dataset(dataset_path, split="train")
|
15 |
+
class_names = train_dataset.features["label"].names
|
16 |
+
|
17 |
+
# Load ViT model
|
18 |
+
model = ViTForImageClassification.from_pretrained(
|
19 |
+
"./models",
|
20 |
+
num_labels=len(class_names),
|
21 |
+
id2label={str(i): label for i, label in enumerate(class_names)},
|
22 |
+
label2id={label: i for i, label in enumerate(class_names)},
|
23 |
+
)
|
24 |
+
|
25 |
+
# Set model to evaluation mode
|
26 |
+
model.eval()
|
27 |
+
|
28 |
+
|
29 |
+
# Define the classification function
|
30 |
+
def classify_image(img_path):
|
31 |
+
img = Image.open(img_path)
|
32 |
+
processed_input = processor(images=img, return_tensors="pt")
|
33 |
+
with torch.no_grad():
|
34 |
+
outputs = model(**processed_input)
|
35 |
+
logits = outputs.logits
|
36 |
+
probabilities = torch.softmax(logits, dim=1)[0].tolist()
|
37 |
+
|
38 |
+
result = {class_name: prob for class_name, prob in zip(class_names, probabilities)}
|
39 |
+
filename = os.path.basename(img_path)
|
40 |
+
return {"filename": filename, "probabilities": result}
|
41 |
+
|
42 |
+
|
43 |
+
def format_output(output):
|
44 |
+
return f"{output['filename']}", output["probabilities"]
|
45 |
+
|
46 |
+
|
47 |
+
# Function to load examples from a folder
|
48 |
+
def load_examples_from_folder(folder_path):
|
49 |
+
examples = []
|
50 |
+
for file in os.listdir(folder_path):
|
51 |
+
if file.endswith((".png", ".jpg", ".jpeg")):
|
52 |
+
examples.append(os.path.join(folder_path, file))
|
53 |
+
return examples
|
54 |
+
|
55 |
+
|
56 |
+
# Define the path to the examples folder
|
57 |
+
examples_folder = "./examples"
|
58 |
+
examples = load_examples_from_folder(examples_folder)
|
59 |
+
|
60 |
+
# Create the Gradio interface
|
61 |
+
iface = gr.Interface(
|
62 |
+
fn=lambda img: format_output(classify_image(img)),
|
63 |
+
inputs=gr.Image(type="filepath"),
|
64 |
+
outputs=[gr.Textbox(label="Filename"), gr.Label()],
|
65 |
+
examples=examples,
|
66 |
+
title="Pneumonia X-Ray Classification",
|
67 |
+
description="Upload an X-ray image to classify it as normal or pneumonia.",
|
68 |
+
)
|
69 |
+
|
70 |
+
# Launch the app
|
71 |
+
if __name__ == "__main__":
|
72 |
+
iface.launch()
|
.history/app_20240617175900.py
ADDED
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import gradio as gr
|
3 |
+
from PIL import Image
|
4 |
+
import torch
|
5 |
+
from transformers import ViTForImageClassification, ViTImageProcessor
|
6 |
+
from datasets import load_dataset
|
7 |
+
|
8 |
+
# Model and processor configuration
|
9 |
+
model_name_or_path = "google/vit-base-patch16-224-in21k"
|
10 |
+
processor = ViTImageProcessor.from_pretrained(model_name_or_path)
|
11 |
+
|
12 |
+
# Load dataset (adjust dataset_path accordingly)
|
13 |
+
dataset_path = "pawlo2013/chest_xray"
|
14 |
+
train_dataset = load_dataset(dataset_path, split="train")
|
15 |
+
class_names = train_dataset.features["label"].names
|
16 |
+
|
17 |
+
# Load ViT model
|
18 |
+
model = ViTForImageClassification.from_pretrained(
|
19 |
+
"./models",
|
20 |
+
num_labels=len(class_names),
|
21 |
+
id2label={str(i): label for i, label in enumerate(class_names)},
|
22 |
+
label2id={label: i for i, label in enumerate(class_names)},
|
23 |
+
)
|
24 |
+
|
25 |
+
# Set model to evaluation mode
|
26 |
+
model.eval()
|
27 |
+
|
28 |
+
|
29 |
+
# Define the classification function
|
30 |
+
def classify_image(img_path):
|
31 |
+
img = Image.open(img_path)
|
32 |
+
processed_input = processor(images=img, return_tensors="pt")
|
33 |
+
with torch.no_grad():
|
34 |
+
outputs = model(**processed_input)
|
35 |
+
logits = outputs.logits
|
36 |
+
probabilities = torch.softmax(logits, dim=1)[0].tolist()
|
37 |
+
|
38 |
+
result = {class_name: prob for class_name, prob in zip(class_names, probabilities)}
|
39 |
+
filename = os.path.basename(img_path).split(".")[0]
|
40 |
+
return {"filename": filename, "probabilities": result}
|
41 |
+
|
42 |
+
|
43 |
+
def format_output(output):
|
44 |
+
return f"{output['filename']}", output["probabilities"]
|
45 |
+
|
46 |
+
|
47 |
+
# Function to load examples from a folder
|
48 |
+
def load_examples_from_folder(folder_path):
|
49 |
+
examples = []
|
50 |
+
for file in os.listdir(folder_path):
|
51 |
+
if file.endswith((".png", ".jpg", ".jpeg")):
|
52 |
+
examples.append(os.path.join(folder_path, file))
|
53 |
+
return examples
|
54 |
+
|
55 |
+
|
56 |
+
# Define the path to the examples folder
|
57 |
+
examples_folder = "./examples"
|
58 |
+
examples = load_examples_from_folder(examples_folder)
|
59 |
+
|
60 |
+
# Create the Gradio interface
|
61 |
+
iface = gr.Interface(
|
62 |
+
fn=lambda img: format_output(classify_image(img)),
|
63 |
+
inputs=gr.Image(type="filepath"),
|
64 |
+
outputs=[gr.Textbox(label="Filename"), gr.Label()],
|
65 |
+
examples=examples,
|
66 |
+
title="Pneumonia X-Ray Classification",
|
67 |
+
description="Upload an X-ray image to classify it as normal or pneumonia.",
|
68 |
+
)
|
69 |
+
|
70 |
+
# Launch the app
|
71 |
+
if __name__ == "__main__":
|
72 |
+
iface.launch()
|
.history/app_20240617175913.py
ADDED
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import gradio as gr
|
3 |
+
from PIL import Image
|
4 |
+
import torch
|
5 |
+
from transformers import ViTForImageClassification, ViTImageProcessor
|
6 |
+
from datasets import load_dataset
|
7 |
+
|
8 |
+
# Model and processor configuration
|
9 |
+
model_name_or_path = "google/vit-base-patch16-224-in21k"
|
10 |
+
processor = ViTImageProcessor.from_pretrained(model_name_or_path)
|
11 |
+
|
12 |
+
# Load dataset (adjust dataset_path accordingly)
|
13 |
+
dataset_path = "pawlo2013/chest_xray"
|
14 |
+
train_dataset = load_dataset(dataset_path, split="train")
|
15 |
+
class_names = train_dataset.features["label"].names
|
16 |
+
|
17 |
+
# Load ViT model
|
18 |
+
model = ViTForImageClassification.from_pretrained(
|
19 |
+
"./models",
|
20 |
+
num_labels=len(class_names),
|
21 |
+
id2label={str(i): label for i, label in enumerate(class_names)},
|
22 |
+
label2id={label: i for i, label in enumerate(class_names)},
|
23 |
+
)
|
24 |
+
|
25 |
+
# Set model to evaluation mode
|
26 |
+
model.eval()
|
27 |
+
|
28 |
+
|
29 |
+
# Define the classification function
|
30 |
+
def classify_image(img_path):
|
31 |
+
img = Image.open(img_path)
|
32 |
+
processed_input = processor(images=img, return_tensors="pt")
|
33 |
+
with torch.no_grad():
|
34 |
+
outputs = model(**processed_input)
|
35 |
+
logits = outputs.logits
|
36 |
+
probabilities = torch.softmax(logits, dim=1)[0].tolist()
|
37 |
+
|
38 |
+
result = {class_name: prob for class_name, prob in zip(class_names, probabilities)}
|
39 |
+
filename = os.path.basename(img_path).split(".")[0]
|
40 |
+
return {"filename": filename, "probabilities": result}
|
41 |
+
|
42 |
+
|
43 |
+
def format_output(output):
|
44 |
+
return f"{output['filename']}", output["probabilities"]
|
45 |
+
|
46 |
+
|
47 |
+
# Function to load examples from a folder
|
48 |
+
def load_examples_from_folder(folder_path):
|
49 |
+
examples = []
|
50 |
+
for file in os.listdir(folder_path):
|
51 |
+
if file.endswith((".png", ".jpg", ".jpeg")):
|
52 |
+
examples.append(os.path.join(folder_path, file))
|
53 |
+
return examples
|
54 |
+
|
55 |
+
|
56 |
+
# Define the path to the examples folder
|
57 |
+
examples_folder = "./examples"
|
58 |
+
examples = load_examples_from_folder(examples_folder)
|
59 |
+
|
60 |
+
# Create the Gradio interface
|
61 |
+
iface = gr.Interface(
|
62 |
+
fn=lambda img: format_output(classify_image(img)),
|
63 |
+
inputs=gr.Image(type="filepath"),
|
64 |
+
outputs=[gr.Textbox(label="True Label"), gr.Label()],
|
65 |
+
examples=examples,
|
66 |
+
title="Pneumonia X-Ray Classification",
|
67 |
+
description="Upload an X-ray image to classify it as normal or pneumonia.",
|
68 |
+
)
|
69 |
+
|
70 |
+
# Launch the app
|
71 |
+
if __name__ == "__main__":
|
72 |
+
iface.launch()
|
.history/app_20240617175920.py
ADDED
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import gradio as gr
|
3 |
+
from PIL import Image
|
4 |
+
import torch
|
5 |
+
from transformers import ViTForImageClassification, ViTImageProcessor
|
6 |
+
from datasets import load_dataset
|
7 |
+
|
8 |
+
# Model and processor configuration
|
9 |
+
model_name_or_path = "google/vit-base-patch16-224-in21k"
|
10 |
+
processor = ViTImageProcessor.from_pretrained(model_name_or_path)
|
11 |
+
|
12 |
+
# Load dataset (adjust dataset_path accordingly)
|
13 |
+
dataset_path = "pawlo2013/chest_xray"
|
14 |
+
train_dataset = load_dataset(dataset_path, split="train")
|
15 |
+
class_names = train_dataset.features["label"].names
|
16 |
+
|
17 |
+
# Load ViT model
|
18 |
+
model = ViTForImageClassification.from_pretrained(
|
19 |
+
"./models",
|
20 |
+
num_labels=len(class_names),
|
21 |
+
id2label={str(i): label for i, label in enumerate(class_names)},
|
22 |
+
label2id={label: i for i, label in enumerate(class_names)},
|
23 |
+
)
|
24 |
+
|
25 |
+
# Set model to evaluation mode
|
26 |
+
model.eval()
|
27 |
+
|
28 |
+
|
29 |
+
# Define the classification function
|
30 |
+
def classify_image(img_path):
|
31 |
+
img = Image.open(img_path)
|
32 |
+
processed_input = processor(images=img, return_tensors="pt")
|
33 |
+
with torch.no_grad():
|
34 |
+
outputs = model(**processed_input)
|
35 |
+
logits = outputs.logits
|
36 |
+
probabilities = torch.softmax(logits, dim=1)[0].tolist()
|
37 |
+
|
38 |
+
result = {class_name: prob for class_name, prob in zip(class_names, probabilities)}
|
39 |
+
filename = os.path.basename(img_path).split(".")[0]
|
40 |
+
return {"filename": filename, "probabilities": result}
|
41 |
+
|
42 |
+
|
43 |
+
def format_output(output):
|
44 |
+
return f"{output['filename']}", output["probabilities"]
|
45 |
+
|
46 |
+
|
47 |
+
# Function to load examples from a folder
|
48 |
+
def load_examples_from_folder(folder_path):
|
49 |
+
examples = []
|
50 |
+
for file in os.listdir(folder_path):
|
51 |
+
if file.endswith((".png", ".jpg", ".jpeg")):
|
52 |
+
examples.append(os.path.join(folder_path, file))
|
53 |
+
return examples
|
54 |
+
|
55 |
+
|
56 |
+
# Define the path to the examples folder
|
57 |
+
examples_folder = "./examples"
|
58 |
+
examples = load_examples_from_folder(examples_folder)
|
59 |
+
|
60 |
+
# Create the Gradio interface
|
61 |
+
iface = gr.Interface(
|
62 |
+
fn=lambda img: format_output(classify_image(img)),
|
63 |
+
inputs=gr.Image(type="filepath"),
|
64 |
+
outputs=[gr.Textbox(label="True Label (from filename)"), gr.Label()],
|
65 |
+
examples=examples,
|
66 |
+
title="Pneumonia X-Ray Classification",
|
67 |
+
description="Upload an X-ray image to classify it as normal or pneumonia.",
|
68 |
+
)
|
69 |
+
|
70 |
+
# Launch the app
|
71 |
+
if __name__ == "__main__":
|
72 |
+
iface.launch()
|
.history/app_20240617175957.py
ADDED
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import gradio as gr
|
3 |
+
from PIL import Image
|
4 |
+
import torch
|
5 |
+
from transformers import ViTForImageClassification, ViTImageProcessor
|
6 |
+
from datasets import load_dataset
|
7 |
+
|
8 |
+
# Model and processor configuration
|
9 |
+
model_name_or_path = "google/vit-base-patch16-224-in21k"
|
10 |
+
processor = ViTImageProcessor.from_pretrained(model_name_or_path)
|
11 |
+
|
12 |
+
# Load dataset (adjust dataset_path accordingly)
|
13 |
+
dataset_path = "pawlo2013/chest_xray"
|
14 |
+
train_dataset = load_dataset(dataset_path, split="train")
|
15 |
+
class_names = train_dataset.features["label"].names
|
16 |
+
|
17 |
+
# Load ViT model
|
18 |
+
model = ViTForImageClassification.from_pretrained(
|
19 |
+
"./models",
|
20 |
+
num_labels=len(class_names),
|
21 |
+
id2label={str(i): label for i, label in enumerate(class_names)},
|
22 |
+
label2id={label: i for i, label in enumerate(class_names)},
|
23 |
+
)
|
24 |
+
|
25 |
+
# Set model to evaluation mode
|
26 |
+
model.eval()
|
27 |
+
|
28 |
+
|
29 |
+
# Define the classification function
|
30 |
+
def classify_image(img_path):
|
31 |
+
img = Image.open(img_path)
|
32 |
+
processed_input = processor(images=img, return_tensors="pt")
|
33 |
+
with torch.no_grad():
|
34 |
+
outputs = model(**processed_input)
|
35 |
+
logits = outputs.logits
|
36 |
+
probabilities = torch.softmax(logits, dim=1)[0].tolist()
|
37 |
+
|
38 |
+
result = {class_name: prob for class_name, prob in zip(class_names, probabilities)}
|
39 |
+
filename = os.path.basename(img_path).split(".")[0]
|
40 |
+
return {"filename": filename, "probabilities": result}
|
41 |
+
|
42 |
+
|
43 |
+
def format_output(output):
|
44 |
+
return f"{output['filename']}", output["probabilities"]
|
45 |
+
|
46 |
+
|
47 |
+
# Function to load examples from a folder
|
48 |
+
def load_examples_from_folder(folder_path):
|
49 |
+
examples = []
|
50 |
+
for file in os.listdir(folder_path):
|
51 |
+
if file.endswith((".png", ".jpg", ".jpeg")):
|
52 |
+
examples.append(os.path.join(folder_path, file))
|
53 |
+
return examples
|
54 |
+
|
55 |
+
|
56 |
+
# Define the path to the examples folder
|
57 |
+
examples_folder = "./examples"
|
58 |
+
examples = load_examples_from_folder(examples_folder)
|
59 |
+
|
60 |
+
# Create the Gradio interface
|
61 |
+
iface = gr.Interface(
|
62 |
+
fn=lambda img: format_output(classify_image(img)),
|
63 |
+
inputs=gr.Image(type="filepath"),
|
64 |
+
outputs=[gr.Textbox(label="True Label (from filename)"), gr.Label()],
|
65 |
+
examples=examples,
|
66 |
+
title="Pneumonia X-Ray 3-Class Classification with Vision Transformer (ViT)",
|
67 |
+
description="Upload an X-ray image to classify it as normal or pneumonia.",
|
68 |
+
)
|
69 |
+
|
70 |
+
# Launch the app
|
71 |
+
if __name__ == "__main__":
|
72 |
+
iface.launch()
|
.history/app_20240617180016.py
ADDED
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import gradio as gr
|
3 |
+
from PIL import Image
|
4 |
+
import torch
|
5 |
+
from transformers import ViTForImageClassification, ViTImageProcessor
|
6 |
+
from datasets import load_dataset
|
7 |
+
|
8 |
+
# Model and processor configuration
|
9 |
+
model_name_or_path = "google/vit-base-patch16-224-in21k"
|
10 |
+
processor = ViTImageProcessor.from_pretrained(model_name_or_path)
|
11 |
+
|
12 |
+
# Load dataset (adjust dataset_path accordingly)
|
13 |
+
dataset_path = "pawlo2013/chest_xray"
|
14 |
+
train_dataset = load_dataset(dataset_path, split="train")
|
15 |
+
class_names = train_dataset.features["label"].names
|
16 |
+
|
17 |
+
# Load ViT model
|
18 |
+
model = ViTForImageClassification.from_pretrained(
|
19 |
+
"./models",
|
20 |
+
num_labels=len(class_names),
|
21 |
+
id2label={str(i): label for i, label in enumerate(class_names)},
|
22 |
+
label2id={label: i for i, label in enumerate(class_names)},
|
23 |
+
)
|
24 |
+
|
25 |
+
# Set model to evaluation mode
|
26 |
+
model.eval()
|
27 |
+
|
28 |
+
|
29 |
+
# Define the classification function
|
30 |
+
def classify_image(img_path):
|
31 |
+
img = Image.open(img_path)
|
32 |
+
processed_input = processor(images=img, return_tensors="pt")
|
33 |
+
with torch.no_grad():
|
34 |
+
outputs = model(**processed_input)
|
35 |
+
logits = outputs.logits
|
36 |
+
probabilities = torch.softmax(logits, dim=1)[0].tolist()
|
37 |
+
|
38 |
+
result = {class_name: prob for class_name, prob in zip(class_names, probabilities)}
|
39 |
+
filename = os.path.basename(img_path).split(".")[0]
|
40 |
+
return {"filename": filename, "probabilities": result}
|
41 |
+
|
42 |
+
|
43 |
+
def format_output(output):
|
44 |
+
return f"{output['filename']}", output["probabilities"]
|
45 |
+
|
46 |
+
|
47 |
+
# Function to load examples from a folder
|
48 |
+
def load_examples_from_folder(folder_path):
|
49 |
+
examples = []
|
50 |
+
for file in os.listdir(folder_path):
|
51 |
+
if file.endswith((".png", ".jpg", ".jpeg")):
|
52 |
+
examples.append(os.path.join(folder_path, file))
|
53 |
+
return examples
|
54 |
+
|
55 |
+
|
56 |
+
# Define the path to the examples folder
|
57 |
+
examples_folder = "./examples"
|
58 |
+
examples = load_examples_from_folder(examples_folder)
|
59 |
+
|
60 |
+
# Create the Gradio interface
|
61 |
+
iface = gr.Interface(
|
62 |
+
fn=lambda img: format_output(classify_image(img)),
|
63 |
+
inputs=gr.Image(type="filepath"),
|
64 |
+
outputs=[gr.Textbox(label="True Label (from filename)"), gr.Label()],
|
65 |
+
examples=examples,
|
66 |
+
title="Pneumonia X-Ray 3-Class Classification with Vision Transformer (ViT)",
|
67 |
+
description="Upload an X-ray image to classify it as normal, viral or bacterial pneumonia.",
|
68 |
+
)
|
69 |
+
|
70 |
+
# Launch the app
|
71 |
+
if __name__ == "__main__":
|
72 |
+
iface.launch()
|
app.py
CHANGED
@@ -1,3 +1,72 @@
|
|
|
|
1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
2 |
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
import gradio as gr
|
3 |
+
from PIL import Image
|
4 |
+
import torch
|
5 |
+
from transformers import ViTForImageClassification, ViTImageProcessor
|
6 |
+
from datasets import load_dataset
|
7 |
|
8 |
+
# Model and processor configuration
|
9 |
+
model_name_or_path = "google/vit-base-patch16-224-in21k"
|
10 |
+
processor = ViTImageProcessor.from_pretrained(model_name_or_path)
|
11 |
+
|
12 |
+
# Load dataset (adjust dataset_path accordingly)
|
13 |
+
dataset_path = "pawlo2013/chest_xray"
|
14 |
+
train_dataset = load_dataset(dataset_path, split="train")
|
15 |
+
class_names = train_dataset.features["label"].names
|
16 |
+
|
17 |
+
# Load ViT model
|
18 |
+
model = ViTForImageClassification.from_pretrained(
|
19 |
+
"./models",
|
20 |
+
num_labels=len(class_names),
|
21 |
+
id2label={str(i): label for i, label in enumerate(class_names)},
|
22 |
+
label2id={label: i for i, label in enumerate(class_names)},
|
23 |
+
)
|
24 |
+
|
25 |
+
# Set model to evaluation mode
|
26 |
+
model.eval()
|
27 |
+
|
28 |
+
|
29 |
+
# Define the classification function
|
30 |
+
def classify_image(img_path):
|
31 |
+
img = Image.open(img_path)
|
32 |
+
processed_input = processor(images=img, return_tensors="pt")
|
33 |
+
with torch.no_grad():
|
34 |
+
outputs = model(**processed_input)
|
35 |
+
logits = outputs.logits
|
36 |
+
probabilities = torch.softmax(logits, dim=1)[0].tolist()
|
37 |
+
|
38 |
+
result = {class_name: prob for class_name, prob in zip(class_names, probabilities)}
|
39 |
+
filename = os.path.basename(img_path).split(".")[0]
|
40 |
+
return {"filename": filename, "probabilities": result}
|
41 |
+
|
42 |
+
|
43 |
+
def format_output(output):
|
44 |
+
return f"{output['filename']}", output["probabilities"]
|
45 |
+
|
46 |
+
|
47 |
+
# Function to load examples from a folder
|
48 |
+
def load_examples_from_folder(folder_path):
|
49 |
+
examples = []
|
50 |
+
for file in os.listdir(folder_path):
|
51 |
+
if file.endswith((".png", ".jpg", ".jpeg")):
|
52 |
+
examples.append(os.path.join(folder_path, file))
|
53 |
+
return examples
|
54 |
+
|
55 |
+
|
56 |
+
# Define the path to the examples folder
|
57 |
+
examples_folder = "./examples"
|
58 |
+
examples = load_examples_from_folder(examples_folder)
|
59 |
+
|
60 |
+
# Create the Gradio interface
|
61 |
+
iface = gr.Interface(
|
62 |
+
fn=lambda img: format_output(classify_image(img)),
|
63 |
+
inputs=gr.Image(type="filepath"),
|
64 |
+
outputs=[gr.Textbox(label="True Label (from filename)"), gr.Label()],
|
65 |
+
examples=examples,
|
66 |
+
title="Pneumonia X-Ray 3-Class Classification with Vision Transformer (ViT)",
|
67 |
+
description="Upload an X-ray image to classify it as normal, viral or bacterial pneumonia.",
|
68 |
+
)
|
69 |
+
|
70 |
+
# Launch the app
|
71 |
+
if __name__ == "__main__":
|
72 |
+
iface.launch()
|
examples/Bacterial.jpeg
ADDED
![]() |
examples/Normal.jpeg
ADDED
![]() |
examples/Viral.jpeg
ADDED
![]() |
models/config.json
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_name_or_path": "google/vit-base-patch16-224-in21k",
|
3 |
+
"architectures": [
|
4 |
+
"ViTForImageClassification"
|
5 |
+
],
|
6 |
+
"attention_probs_dropout_prob": 0.0,
|
7 |
+
"encoder_stride": 16,
|
8 |
+
"hidden_act": "gelu",
|
9 |
+
"hidden_dropout_prob": 0.0,
|
10 |
+
"hidden_size": 768,
|
11 |
+
"id2label": {
|
12 |
+
"0": "LABEL_0",
|
13 |
+
"1": "LABEL_1",
|
14 |
+
"2": "LABEL_2"
|
15 |
+
},
|
16 |
+
"image_size": 224,
|
17 |
+
"initializer_range": 0.02,
|
18 |
+
"intermediate_size": 3072,
|
19 |
+
"label2id": {
|
20 |
+
"LABEL_0": 0,
|
21 |
+
"LABEL_1": 1,
|
22 |
+
"LABEL_2": 2
|
23 |
+
},
|
24 |
+
"layer_norm_eps": 1e-12,
|
25 |
+
"model_type": "vit",
|
26 |
+
"num_attention_heads": 12,
|
27 |
+
"num_channels": 3,
|
28 |
+
"num_hidden_layers": 12,
|
29 |
+
"patch_size": 16,
|
30 |
+
"problem_type": "single_label_classification",
|
31 |
+
"qkv_bias": true,
|
32 |
+
"torch_dtype": "float32",
|
33 |
+
"transformers_version": "4.38.1"
|
34 |
+
}
|
models/model.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:7259957cb4dd213d39e5d536abde8da37aa08cf56c729541f5e87a5fa6faa33f
|
3 |
+
size 343227052
|
models/optimizer.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e273e892c8cb94bf00a5d414bc46df66f9f53bd7359d3572b918f22b98ce4b93
|
3 |
+
size 56750370
|
models/preprocessor_config.json
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"do_normalize": true,
|
3 |
+
"do_rescale": true,
|
4 |
+
"do_resize": true,
|
5 |
+
"image_mean": [
|
6 |
+
0.5,
|
7 |
+
0.5,
|
8 |
+
0.5
|
9 |
+
],
|
10 |
+
"image_processor_type": "ViTImageProcessor",
|
11 |
+
"image_std": [
|
12 |
+
0.5,
|
13 |
+
0.5,
|
14 |
+
0.5
|
15 |
+
],
|
16 |
+
"resample": 2,
|
17 |
+
"rescale_factor": 0.00392156862745098,
|
18 |
+
"size": {
|
19 |
+
"height": 224,
|
20 |
+
"width": 224
|
21 |
+
}
|
22 |
+
}
|
models/rng_state.pth
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e61ed5a12974ddc84aba2cf0e3ebe942a9f431b3349c3ae1f29a37ab202683c4
|
3 |
+
size 13990
|
models/scheduler.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:665e0ada3e15db3564e43a6ff9d215f31f6a3ac1540edfe099d0df6966ec7aa8
|
3 |
+
size 1064
|
models/trainer_state.json
ADDED
@@ -0,0 +1,1551 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"best_metric": 0.7440524101257324,
|
3 |
+
"best_model_checkpoint": "./vit-pneumonia-x-ray_data_augmentation_frozen_model/checkpoint-1800",
|
4 |
+
"epoch": 12.32876712328767,
|
5 |
+
"eval_steps": 100,
|
6 |
+
"global_step": 1800,
|
7 |
+
"is_hyper_param_search": false,
|
8 |
+
"is_local_process_zero": true,
|
9 |
+
"is_world_process_zero": true,
|
10 |
+
"log_history": [
|
11 |
+
{
|
12 |
+
"epoch": 0.07,
|
13 |
+
"grad_norm": 1.2999861240386963,
|
14 |
+
"learning_rate": 0.0009986301369863013,
|
15 |
+
"loss": 0.9052,
|
16 |
+
"step": 10
|
17 |
+
},
|
18 |
+
{
|
19 |
+
"epoch": 0.14,
|
20 |
+
"grad_norm": 1.1751593351364136,
|
21 |
+
"learning_rate": 0.0009972602739726027,
|
22 |
+
"loss": 0.7342,
|
23 |
+
"step": 20
|
24 |
+
},
|
25 |
+
{
|
26 |
+
"epoch": 0.21,
|
27 |
+
"grad_norm": 1.3162366151809692,
|
28 |
+
"learning_rate": 0.000995890410958904,
|
29 |
+
"loss": 0.6777,
|
30 |
+
"step": 30
|
31 |
+
},
|
32 |
+
{
|
33 |
+
"epoch": 0.27,
|
34 |
+
"grad_norm": 1.1881186962127686,
|
35 |
+
"learning_rate": 0.0009945205479452055,
|
36 |
+
"loss": 0.6455,
|
37 |
+
"step": 40
|
38 |
+
},
|
39 |
+
{
|
40 |
+
"epoch": 0.34,
|
41 |
+
"grad_norm": 4.0501508712768555,
|
42 |
+
"learning_rate": 0.0009931506849315068,
|
43 |
+
"loss": 0.6433,
|
44 |
+
"step": 50
|
45 |
+
},
|
46 |
+
{
|
47 |
+
"epoch": 0.41,
|
48 |
+
"grad_norm": 2.4241373538970947,
|
49 |
+
"learning_rate": 0.0009917808219178082,
|
50 |
+
"loss": 0.6633,
|
51 |
+
"step": 60
|
52 |
+
},
|
53 |
+
{
|
54 |
+
"epoch": 0.48,
|
55 |
+
"grad_norm": 1.7584506273269653,
|
56 |
+
"learning_rate": 0.0009904109589041095,
|
57 |
+
"loss": 0.5253,
|
58 |
+
"step": 70
|
59 |
+
},
|
60 |
+
{
|
61 |
+
"epoch": 0.55,
|
62 |
+
"grad_norm": 1.115493893623352,
|
63 |
+
"learning_rate": 0.000989041095890411,
|
64 |
+
"loss": 0.5291,
|
65 |
+
"step": 80
|
66 |
+
},
|
67 |
+
{
|
68 |
+
"epoch": 0.62,
|
69 |
+
"grad_norm": 1.0183758735656738,
|
70 |
+
"learning_rate": 0.0009876712328767123,
|
71 |
+
"loss": 0.5742,
|
72 |
+
"step": 90
|
73 |
+
},
|
74 |
+
{
|
75 |
+
"epoch": 0.68,
|
76 |
+
"grad_norm": 1.7618106603622437,
|
77 |
+
"learning_rate": 0.0009863013698630137,
|
78 |
+
"loss": 0.5098,
|
79 |
+
"step": 100
|
80 |
+
},
|
81 |
+
{
|
82 |
+
"epoch": 0.68,
|
83 |
+
"eval_accuracy": 0.7198443579766537,
|
84 |
+
"eval_accuracy_class_Bacterial": 0.84375,
|
85 |
+
"eval_accuracy_class_Normal": 0.7967479674796748,
|
86 |
+
"eval_accuracy_class_Viral": 0.4148148148148148,
|
87 |
+
"eval_f1": 0.7061270215472498,
|
88 |
+
"eval_loss": 0.8028925657272339,
|
89 |
+
"eval_precision": 0.727092782714888,
|
90 |
+
"eval_recall": 0.7198443579766537,
|
91 |
+
"eval_runtime": 42.6101,
|
92 |
+
"eval_samples_per_second": 12.063,
|
93 |
+
"eval_steps_per_second": 0.399,
|
94 |
+
"step": 100
|
95 |
+
},
|
96 |
+
{
|
97 |
+
"epoch": 0.75,
|
98 |
+
"grad_norm": 0.9144254326820374,
|
99 |
+
"learning_rate": 0.000984931506849315,
|
100 |
+
"loss": 0.5965,
|
101 |
+
"step": 110
|
102 |
+
},
|
103 |
+
{
|
104 |
+
"epoch": 0.82,
|
105 |
+
"grad_norm": 0.9542173743247986,
|
106 |
+
"learning_rate": 0.0009835616438356163,
|
107 |
+
"loss": 0.5742,
|
108 |
+
"step": 120
|
109 |
+
},
|
110 |
+
{
|
111 |
+
"epoch": 0.89,
|
112 |
+
"grad_norm": 1.90875244140625,
|
113 |
+
"learning_rate": 0.0009821917808219179,
|
114 |
+
"loss": 0.5374,
|
115 |
+
"step": 130
|
116 |
+
},
|
117 |
+
{
|
118 |
+
"epoch": 0.96,
|
119 |
+
"grad_norm": 0.8156168460845947,
|
120 |
+
"learning_rate": 0.0009808219178082192,
|
121 |
+
"loss": 0.5118,
|
122 |
+
"step": 140
|
123 |
+
},
|
124 |
+
{
|
125 |
+
"epoch": 1.03,
|
126 |
+
"grad_norm": 1.6298660039901733,
|
127 |
+
"learning_rate": 0.0009794520547945205,
|
128 |
+
"loss": 0.5168,
|
129 |
+
"step": 150
|
130 |
+
},
|
131 |
+
{
|
132 |
+
"epoch": 1.1,
|
133 |
+
"grad_norm": 0.5898642539978027,
|
134 |
+
"learning_rate": 0.0009780821917808218,
|
135 |
+
"loss": 0.5665,
|
136 |
+
"step": 160
|
137 |
+
},
|
138 |
+
{
|
139 |
+
"epoch": 1.16,
|
140 |
+
"grad_norm": 1.1714237928390503,
|
141 |
+
"learning_rate": 0.0009767123287671234,
|
142 |
+
"loss": 0.5061,
|
143 |
+
"step": 170
|
144 |
+
},
|
145 |
+
{
|
146 |
+
"epoch": 1.23,
|
147 |
+
"grad_norm": 1.8745484352111816,
|
148 |
+
"learning_rate": 0.0009753424657534247,
|
149 |
+
"loss": 0.4868,
|
150 |
+
"step": 180
|
151 |
+
},
|
152 |
+
{
|
153 |
+
"epoch": 1.3,
|
154 |
+
"grad_norm": 0.7712134718894958,
|
155 |
+
"learning_rate": 0.0009739726027397261,
|
156 |
+
"loss": 0.5125,
|
157 |
+
"step": 190
|
158 |
+
},
|
159 |
+
{
|
160 |
+
"epoch": 1.37,
|
161 |
+
"grad_norm": 0.753567099571228,
|
162 |
+
"learning_rate": 0.0009726027397260274,
|
163 |
+
"loss": 0.4609,
|
164 |
+
"step": 200
|
165 |
+
},
|
166 |
+
{
|
167 |
+
"epoch": 1.37,
|
168 |
+
"eval_accuracy": 0.7509727626459144,
|
169 |
+
"eval_accuracy_class_Bacterial": 0.8125,
|
170 |
+
"eval_accuracy_class_Normal": 0.7804878048780488,
|
171 |
+
"eval_accuracy_class_Viral": 0.6074074074074074,
|
172 |
+
"eval_f1": 0.7503972489190844,
|
173 |
+
"eval_loss": 0.759770393371582,
|
174 |
+
"eval_precision": 0.753673142519536,
|
175 |
+
"eval_recall": 0.7509727626459144,
|
176 |
+
"eval_runtime": 38.2089,
|
177 |
+
"eval_samples_per_second": 13.452,
|
178 |
+
"eval_steps_per_second": 0.445,
|
179 |
+
"step": 200
|
180 |
+
},
|
181 |
+
{
|
182 |
+
"epoch": 1.44,
|
183 |
+
"grad_norm": 0.7043547034263611,
|
184 |
+
"learning_rate": 0.0009712328767123288,
|
185 |
+
"loss": 0.4749,
|
186 |
+
"step": 210
|
187 |
+
},
|
188 |
+
{
|
189 |
+
"epoch": 1.51,
|
190 |
+
"grad_norm": 0.5875887274742126,
|
191 |
+
"learning_rate": 0.0009698630136986302,
|
192 |
+
"loss": 0.4831,
|
193 |
+
"step": 220
|
194 |
+
},
|
195 |
+
{
|
196 |
+
"epoch": 1.58,
|
197 |
+
"grad_norm": 0.5488404035568237,
|
198 |
+
"learning_rate": 0.0009684931506849315,
|
199 |
+
"loss": 0.5314,
|
200 |
+
"step": 230
|
201 |
+
},
|
202 |
+
{
|
203 |
+
"epoch": 1.64,
|
204 |
+
"grad_norm": 1.2711101770401,
|
205 |
+
"learning_rate": 0.0009671232876712329,
|
206 |
+
"loss": 0.5463,
|
207 |
+
"step": 240
|
208 |
+
},
|
209 |
+
{
|
210 |
+
"epoch": 1.71,
|
211 |
+
"grad_norm": 0.31795018911361694,
|
212 |
+
"learning_rate": 0.0009657534246575343,
|
213 |
+
"loss": 0.5109,
|
214 |
+
"step": 250
|
215 |
+
},
|
216 |
+
{
|
217 |
+
"epoch": 1.78,
|
218 |
+
"grad_norm": 1.2750917673110962,
|
219 |
+
"learning_rate": 0.0009643835616438357,
|
220 |
+
"loss": 0.5053,
|
221 |
+
"step": 260
|
222 |
+
},
|
223 |
+
{
|
224 |
+
"epoch": 1.85,
|
225 |
+
"grad_norm": 0.9569109678268433,
|
226 |
+
"learning_rate": 0.000963013698630137,
|
227 |
+
"loss": 0.4965,
|
228 |
+
"step": 270
|
229 |
+
},
|
230 |
+
{
|
231 |
+
"epoch": 1.92,
|
232 |
+
"grad_norm": 0.9257662892341614,
|
233 |
+
"learning_rate": 0.0009616438356164384,
|
234 |
+
"loss": 0.5175,
|
235 |
+
"step": 280
|
236 |
+
},
|
237 |
+
{
|
238 |
+
"epoch": 1.99,
|
239 |
+
"grad_norm": 0.9531387686729431,
|
240 |
+
"learning_rate": 0.0009602739726027398,
|
241 |
+
"loss": 0.4751,
|
242 |
+
"step": 290
|
243 |
+
},
|
244 |
+
{
|
245 |
+
"epoch": 2.05,
|
246 |
+
"grad_norm": 1.1072851419448853,
|
247 |
+
"learning_rate": 0.0009589041095890411,
|
248 |
+
"loss": 0.482,
|
249 |
+
"step": 300
|
250 |
+
},
|
251 |
+
{
|
252 |
+
"epoch": 2.05,
|
253 |
+
"eval_accuracy": 0.7392996108949417,
|
254 |
+
"eval_accuracy_class_Bacterial": 0.7265625,
|
255 |
+
"eval_accuracy_class_Normal": 0.7804878048780488,
|
256 |
+
"eval_accuracy_class_Viral": 0.725925925925926,
|
257 |
+
"eval_f1": 0.7441369344372653,
|
258 |
+
"eval_loss": 0.7680220603942871,
|
259 |
+
"eval_precision": 0.7562073779920531,
|
260 |
+
"eval_recall": 0.7392996108949417,
|
261 |
+
"eval_runtime": 39.4785,
|
262 |
+
"eval_samples_per_second": 13.02,
|
263 |
+
"eval_steps_per_second": 0.431,
|
264 |
+
"step": 300
|
265 |
+
},
|
266 |
+
{
|
267 |
+
"epoch": 2.12,
|
268 |
+
"grad_norm": 0.49826326966285706,
|
269 |
+
"learning_rate": 0.0009575342465753425,
|
270 |
+
"loss": 0.5238,
|
271 |
+
"step": 310
|
272 |
+
},
|
273 |
+
{
|
274 |
+
"epoch": 2.19,
|
275 |
+
"grad_norm": 2.0074150562286377,
|
276 |
+
"learning_rate": 0.0009561643835616438,
|
277 |
+
"loss": 0.5213,
|
278 |
+
"step": 320
|
279 |
+
},
|
280 |
+
{
|
281 |
+
"epoch": 2.26,
|
282 |
+
"grad_norm": 0.6424590945243835,
|
283 |
+
"learning_rate": 0.0009547945205479453,
|
284 |
+
"loss": 0.4442,
|
285 |
+
"step": 330
|
286 |
+
},
|
287 |
+
{
|
288 |
+
"epoch": 2.33,
|
289 |
+
"grad_norm": 0.5362870097160339,
|
290 |
+
"learning_rate": 0.0009534246575342466,
|
291 |
+
"loss": 0.4302,
|
292 |
+
"step": 340
|
293 |
+
},
|
294 |
+
{
|
295 |
+
"epoch": 2.4,
|
296 |
+
"grad_norm": 0.8034541010856628,
|
297 |
+
"learning_rate": 0.000952054794520548,
|
298 |
+
"loss": 0.4882,
|
299 |
+
"step": 350
|
300 |
+
},
|
301 |
+
{
|
302 |
+
"epoch": 2.47,
|
303 |
+
"grad_norm": 0.7750194072723389,
|
304 |
+
"learning_rate": 0.0009506849315068493,
|
305 |
+
"loss": 0.4668,
|
306 |
+
"step": 360
|
307 |
+
},
|
308 |
+
{
|
309 |
+
"epoch": 2.53,
|
310 |
+
"grad_norm": 0.5913398265838623,
|
311 |
+
"learning_rate": 0.0009493150684931508,
|
312 |
+
"loss": 0.4412,
|
313 |
+
"step": 370
|
314 |
+
},
|
315 |
+
{
|
316 |
+
"epoch": 2.6,
|
317 |
+
"grad_norm": 2.182452917098999,
|
318 |
+
"learning_rate": 0.0009479452054794521,
|
319 |
+
"loss": 0.492,
|
320 |
+
"step": 380
|
321 |
+
},
|
322 |
+
{
|
323 |
+
"epoch": 2.67,
|
324 |
+
"grad_norm": 0.4750209450721741,
|
325 |
+
"learning_rate": 0.0009465753424657535,
|
326 |
+
"loss": 0.4839,
|
327 |
+
"step": 390
|
328 |
+
},
|
329 |
+
{
|
330 |
+
"epoch": 2.74,
|
331 |
+
"grad_norm": 0.8099997639656067,
|
332 |
+
"learning_rate": 0.0009452054794520548,
|
333 |
+
"loss": 0.4513,
|
334 |
+
"step": 400
|
335 |
+
},
|
336 |
+
{
|
337 |
+
"epoch": 2.74,
|
338 |
+
"eval_accuracy": 0.7587548638132295,
|
339 |
+
"eval_accuracy_class_Bacterial": 0.8203125,
|
340 |
+
"eval_accuracy_class_Normal": 0.8048780487804879,
|
341 |
+
"eval_accuracy_class_Viral": 0.6,
|
342 |
+
"eval_f1": 0.7561734408999475,
|
343 |
+
"eval_loss": 0.7605456709861755,
|
344 |
+
"eval_precision": 0.7582411293175139,
|
345 |
+
"eval_recall": 0.7587548638132295,
|
346 |
+
"eval_runtime": 38.7682,
|
347 |
+
"eval_samples_per_second": 13.258,
|
348 |
+
"eval_steps_per_second": 0.439,
|
349 |
+
"step": 400
|
350 |
+
},
|
351 |
+
{
|
352 |
+
"epoch": 2.81,
|
353 |
+
"grad_norm": 0.31849750876426697,
|
354 |
+
"learning_rate": 0.0009438356164383562,
|
355 |
+
"loss": 0.4884,
|
356 |
+
"step": 410
|
357 |
+
},
|
358 |
+
{
|
359 |
+
"epoch": 2.88,
|
360 |
+
"grad_norm": 0.7159171104431152,
|
361 |
+
"learning_rate": 0.0009424657534246576,
|
362 |
+
"loss": 0.492,
|
363 |
+
"step": 420
|
364 |
+
},
|
365 |
+
{
|
366 |
+
"epoch": 2.95,
|
367 |
+
"grad_norm": 0.706955075263977,
|
368 |
+
"learning_rate": 0.0009410958904109589,
|
369 |
+
"loss": 0.4354,
|
370 |
+
"step": 430
|
371 |
+
},
|
372 |
+
{
|
373 |
+
"epoch": 3.01,
|
374 |
+
"grad_norm": 0.8797878623008728,
|
375 |
+
"learning_rate": 0.0009397260273972603,
|
376 |
+
"loss": 0.4362,
|
377 |
+
"step": 440
|
378 |
+
},
|
379 |
+
{
|
380 |
+
"epoch": 3.08,
|
381 |
+
"grad_norm": 1.2229899168014526,
|
382 |
+
"learning_rate": 0.0009383561643835617,
|
383 |
+
"loss": 0.5546,
|
384 |
+
"step": 450
|
385 |
+
},
|
386 |
+
{
|
387 |
+
"epoch": 3.15,
|
388 |
+
"grad_norm": 0.4625228941440582,
|
389 |
+
"learning_rate": 0.0009369863013698631,
|
390 |
+
"loss": 0.4412,
|
391 |
+
"step": 460
|
392 |
+
},
|
393 |
+
{
|
394 |
+
"epoch": 3.22,
|
395 |
+
"grad_norm": 0.7467411160469055,
|
396 |
+
"learning_rate": 0.0009356164383561644,
|
397 |
+
"loss": 0.4433,
|
398 |
+
"step": 470
|
399 |
+
},
|
400 |
+
{
|
401 |
+
"epoch": 3.29,
|
402 |
+
"grad_norm": 0.7149803042411804,
|
403 |
+
"learning_rate": 0.0009342465753424658,
|
404 |
+
"loss": 0.3969,
|
405 |
+
"step": 480
|
406 |
+
},
|
407 |
+
{
|
408 |
+
"epoch": 3.36,
|
409 |
+
"grad_norm": 1.1275142431259155,
|
410 |
+
"learning_rate": 0.0009328767123287672,
|
411 |
+
"loss": 0.4433,
|
412 |
+
"step": 490
|
413 |
+
},
|
414 |
+
{
|
415 |
+
"epoch": 3.42,
|
416 |
+
"grad_norm": 0.5531851649284363,
|
417 |
+
"learning_rate": 0.0009315068493150685,
|
418 |
+
"loss": 0.4367,
|
419 |
+
"step": 500
|
420 |
+
},
|
421 |
+
{
|
422 |
+
"epoch": 3.42,
|
423 |
+
"eval_accuracy": 0.7607003891050583,
|
424 |
+
"eval_accuracy_class_Bacterial": 0.78125,
|
425 |
+
"eval_accuracy_class_Normal": 0.7967479674796748,
|
426 |
+
"eval_accuracy_class_Viral": 0.6888888888888889,
|
427 |
+
"eval_f1": 0.7612120105726318,
|
428 |
+
"eval_loss": 0.7907313108444214,
|
429 |
+
"eval_precision": 0.7620375478182957,
|
430 |
+
"eval_recall": 0.7607003891050583,
|
431 |
+
"eval_runtime": 39.4844,
|
432 |
+
"eval_samples_per_second": 13.018,
|
433 |
+
"eval_steps_per_second": 0.431,
|
434 |
+
"step": 500
|
435 |
+
},
|
436 |
+
{
|
437 |
+
"epoch": 3.49,
|
438 |
+
"grad_norm": 1.5219345092773438,
|
439 |
+
"learning_rate": 0.0009301369863013699,
|
440 |
+
"loss": 0.4563,
|
441 |
+
"step": 510
|
442 |
+
},
|
443 |
+
{
|
444 |
+
"epoch": 3.56,
|
445 |
+
"grad_norm": 0.6871808171272278,
|
446 |
+
"learning_rate": 0.0009287671232876712,
|
447 |
+
"loss": 0.4929,
|
448 |
+
"step": 520
|
449 |
+
},
|
450 |
+
{
|
451 |
+
"epoch": 3.63,
|
452 |
+
"grad_norm": 0.7525418996810913,
|
453 |
+
"learning_rate": 0.0009273972602739727,
|
454 |
+
"loss": 0.4474,
|
455 |
+
"step": 530
|
456 |
+
},
|
457 |
+
{
|
458 |
+
"epoch": 3.7,
|
459 |
+
"grad_norm": 0.3728916049003601,
|
460 |
+
"learning_rate": 0.000926027397260274,
|
461 |
+
"loss": 0.4444,
|
462 |
+
"step": 540
|
463 |
+
},
|
464 |
+
{
|
465 |
+
"epoch": 3.77,
|
466 |
+
"grad_norm": 0.6982372999191284,
|
467 |
+
"learning_rate": 0.0009246575342465754,
|
468 |
+
"loss": 0.394,
|
469 |
+
"step": 550
|
470 |
+
},
|
471 |
+
{
|
472 |
+
"epoch": 3.84,
|
473 |
+
"grad_norm": 0.6600722670555115,
|
474 |
+
"learning_rate": 0.0009232876712328767,
|
475 |
+
"loss": 0.5548,
|
476 |
+
"step": 560
|
477 |
+
},
|
478 |
+
{
|
479 |
+
"epoch": 3.9,
|
480 |
+
"grad_norm": 0.5913540720939636,
|
481 |
+
"learning_rate": 0.0009219178082191782,
|
482 |
+
"loss": 0.4652,
|
483 |
+
"step": 570
|
484 |
+
},
|
485 |
+
{
|
486 |
+
"epoch": 3.97,
|
487 |
+
"grad_norm": 0.2932947874069214,
|
488 |
+
"learning_rate": 0.0009205479452054795,
|
489 |
+
"loss": 0.3682,
|
490 |
+
"step": 580
|
491 |
+
},
|
492 |
+
{
|
493 |
+
"epoch": 4.04,
|
494 |
+
"grad_norm": 0.6950840950012207,
|
495 |
+
"learning_rate": 0.0009191780821917809,
|
496 |
+
"loss": 0.4862,
|
497 |
+
"step": 590
|
498 |
+
},
|
499 |
+
{
|
500 |
+
"epoch": 4.11,
|
501 |
+
"grad_norm": 0.7572476863861084,
|
502 |
+
"learning_rate": 0.0009178082191780823,
|
503 |
+
"loss": 0.4134,
|
504 |
+
"step": 600
|
505 |
+
},
|
506 |
+
{
|
507 |
+
"epoch": 4.11,
|
508 |
+
"eval_accuracy": 0.7587548638132295,
|
509 |
+
"eval_accuracy_class_Bacterial": 0.7734375,
|
510 |
+
"eval_accuracy_class_Normal": 0.7560975609756098,
|
511 |
+
"eval_accuracy_class_Viral": 0.7333333333333333,
|
512 |
+
"eval_f1": 0.762153811730061,
|
513 |
+
"eval_loss": 0.7795141935348511,
|
514 |
+
"eval_precision": 0.7718812461468243,
|
515 |
+
"eval_recall": 0.7587548638132295,
|
516 |
+
"eval_runtime": 39.1561,
|
517 |
+
"eval_samples_per_second": 13.127,
|
518 |
+
"eval_steps_per_second": 0.434,
|
519 |
+
"step": 600
|
520 |
+
},
|
521 |
+
{
|
522 |
+
"epoch": 4.18,
|
523 |
+
"grad_norm": 1.036367416381836,
|
524 |
+
"learning_rate": 0.0009164383561643836,
|
525 |
+
"loss": 0.3799,
|
526 |
+
"step": 610
|
527 |
+
},
|
528 |
+
{
|
529 |
+
"epoch": 4.25,
|
530 |
+
"grad_norm": 1.7970045804977417,
|
531 |
+
"learning_rate": 0.000915068493150685,
|
532 |
+
"loss": 0.4556,
|
533 |
+
"step": 620
|
534 |
+
},
|
535 |
+
{
|
536 |
+
"epoch": 4.32,
|
537 |
+
"grad_norm": 0.6464496850967407,
|
538 |
+
"learning_rate": 0.0009136986301369863,
|
539 |
+
"loss": 0.3978,
|
540 |
+
"step": 630
|
541 |
+
},
|
542 |
+
{
|
543 |
+
"epoch": 4.38,
|
544 |
+
"grad_norm": 1.043805480003357,
|
545 |
+
"learning_rate": 0.0009123287671232878,
|
546 |
+
"loss": 0.3975,
|
547 |
+
"step": 640
|
548 |
+
},
|
549 |
+
{
|
550 |
+
"epoch": 4.45,
|
551 |
+
"grad_norm": 0.627406120300293,
|
552 |
+
"learning_rate": 0.0009109589041095891,
|
553 |
+
"loss": 0.4197,
|
554 |
+
"step": 650
|
555 |
+
},
|
556 |
+
{
|
557 |
+
"epoch": 4.52,
|
558 |
+
"grad_norm": 0.669355034828186,
|
559 |
+
"learning_rate": 0.0009095890410958905,
|
560 |
+
"loss": 0.5468,
|
561 |
+
"step": 660
|
562 |
+
},
|
563 |
+
{
|
564 |
+
"epoch": 4.59,
|
565 |
+
"grad_norm": 0.7727690935134888,
|
566 |
+
"learning_rate": 0.0009082191780821918,
|
567 |
+
"loss": 0.506,
|
568 |
+
"step": 670
|
569 |
+
},
|
570 |
+
{
|
571 |
+
"epoch": 4.66,
|
572 |
+
"grad_norm": 0.4808361828327179,
|
573 |
+
"learning_rate": 0.0009068493150684933,
|
574 |
+
"loss": 0.4329,
|
575 |
+
"step": 680
|
576 |
+
},
|
577 |
+
{
|
578 |
+
"epoch": 4.73,
|
579 |
+
"grad_norm": 0.9221294522285461,
|
580 |
+
"learning_rate": 0.0009054794520547946,
|
581 |
+
"loss": 0.3699,
|
582 |
+
"step": 690
|
583 |
+
},
|
584 |
+
{
|
585 |
+
"epoch": 4.79,
|
586 |
+
"grad_norm": 0.6050639152526855,
|
587 |
+
"learning_rate": 0.0009041095890410959,
|
588 |
+
"loss": 0.5776,
|
589 |
+
"step": 700
|
590 |
+
},
|
591 |
+
{
|
592 |
+
"epoch": 4.79,
|
593 |
+
"eval_accuracy": 0.7723735408560312,
|
594 |
+
"eval_accuracy_class_Bacterial": 0.85546875,
|
595 |
+
"eval_accuracy_class_Normal": 0.7967479674796748,
|
596 |
+
"eval_accuracy_class_Viral": 0.5925925925925926,
|
597 |
+
"eval_f1": 0.7697496825583363,
|
598 |
+
"eval_loss": 0.7780735492706299,
|
599 |
+
"eval_precision": 0.7771621725411038,
|
600 |
+
"eval_recall": 0.7723735408560312,
|
601 |
+
"eval_runtime": 43.4411,
|
602 |
+
"eval_samples_per_second": 11.832,
|
603 |
+
"eval_steps_per_second": 0.391,
|
604 |
+
"step": 700
|
605 |
+
},
|
606 |
+
{
|
607 |
+
"epoch": 4.86,
|
608 |
+
"grad_norm": 1.3572362661361694,
|
609 |
+
"learning_rate": 0.0009027397260273973,
|
610 |
+
"loss": 0.4805,
|
611 |
+
"step": 710
|
612 |
+
},
|
613 |
+
{
|
614 |
+
"epoch": 4.93,
|
615 |
+
"grad_norm": 0.6859280467033386,
|
616 |
+
"learning_rate": 0.0009013698630136987,
|
617 |
+
"loss": 0.4412,
|
618 |
+
"step": 720
|
619 |
+
},
|
620 |
+
{
|
621 |
+
"epoch": 5.0,
|
622 |
+
"grad_norm": 0.9770642518997192,
|
623 |
+
"learning_rate": 0.0009000000000000001,
|
624 |
+
"loss": 0.3328,
|
625 |
+
"step": 730
|
626 |
+
},
|
627 |
+
{
|
628 |
+
"epoch": 5.07,
|
629 |
+
"grad_norm": 0.7935605645179749,
|
630 |
+
"learning_rate": 0.0008986301369863014,
|
631 |
+
"loss": 0.4048,
|
632 |
+
"step": 740
|
633 |
+
},
|
634 |
+
{
|
635 |
+
"epoch": 5.14,
|
636 |
+
"grad_norm": 0.7372242212295532,
|
637 |
+
"learning_rate": 0.0008972602739726028,
|
638 |
+
"loss": 0.4263,
|
639 |
+
"step": 750
|
640 |
+
},
|
641 |
+
{
|
642 |
+
"epoch": 5.21,
|
643 |
+
"grad_norm": 0.8754793405532837,
|
644 |
+
"learning_rate": 0.0008958904109589042,
|
645 |
+
"loss": 0.3936,
|
646 |
+
"step": 760
|
647 |
+
},
|
648 |
+
{
|
649 |
+
"epoch": 5.27,
|
650 |
+
"grad_norm": 1.1648764610290527,
|
651 |
+
"learning_rate": 0.0008945205479452056,
|
652 |
+
"loss": 0.3619,
|
653 |
+
"step": 770
|
654 |
+
},
|
655 |
+
{
|
656 |
+
"epoch": 5.34,
|
657 |
+
"grad_norm": 0.8821219801902771,
|
658 |
+
"learning_rate": 0.0008931506849315069,
|
659 |
+
"loss": 0.3882,
|
660 |
+
"step": 780
|
661 |
+
},
|
662 |
+
{
|
663 |
+
"epoch": 5.41,
|
664 |
+
"grad_norm": 0.9254215359687805,
|
665 |
+
"learning_rate": 0.0008917808219178082,
|
666 |
+
"loss": 0.3538,
|
667 |
+
"step": 790
|
668 |
+
},
|
669 |
+
{
|
670 |
+
"epoch": 5.48,
|
671 |
+
"grad_norm": 0.3486805856227875,
|
672 |
+
"learning_rate": 0.0008904109589041097,
|
673 |
+
"loss": 0.4369,
|
674 |
+
"step": 800
|
675 |
+
},
|
676 |
+
{
|
677 |
+
"epoch": 5.48,
|
678 |
+
"eval_accuracy": 0.7801556420233463,
|
679 |
+
"eval_accuracy_class_Bacterial": 0.80859375,
|
680 |
+
"eval_accuracy_class_Normal": 0.7886178861788617,
|
681 |
+
"eval_accuracy_class_Viral": 0.7185185185185186,
|
682 |
+
"eval_f1": 0.7813822202992926,
|
683 |
+
"eval_loss": 0.8660529851913452,
|
684 |
+
"eval_precision": 0.7850433799518873,
|
685 |
+
"eval_recall": 0.7801556420233463,
|
686 |
+
"eval_runtime": 39.0462,
|
687 |
+
"eval_samples_per_second": 13.164,
|
688 |
+
"eval_steps_per_second": 0.435,
|
689 |
+
"step": 800
|
690 |
+
},
|
691 |
+
{
|
692 |
+
"epoch": 5.55,
|
693 |
+
"grad_norm": 1.4223288297653198,
|
694 |
+
"learning_rate": 0.000889041095890411,
|
695 |
+
"loss": 0.4764,
|
696 |
+
"step": 810
|
697 |
+
},
|
698 |
+
{
|
699 |
+
"epoch": 5.62,
|
700 |
+
"grad_norm": 1.5775070190429688,
|
701 |
+
"learning_rate": 0.0008876712328767124,
|
702 |
+
"loss": 0.4166,
|
703 |
+
"step": 820
|
704 |
+
},
|
705 |
+
{
|
706 |
+
"epoch": 5.68,
|
707 |
+
"grad_norm": 0.44408535957336426,
|
708 |
+
"learning_rate": 0.0008863013698630137,
|
709 |
+
"loss": 0.4337,
|
710 |
+
"step": 830
|
711 |
+
},
|
712 |
+
{
|
713 |
+
"epoch": 5.75,
|
714 |
+
"grad_norm": 0.7388616800308228,
|
715 |
+
"learning_rate": 0.0008849315068493152,
|
716 |
+
"loss": 0.4474,
|
717 |
+
"step": 840
|
718 |
+
},
|
719 |
+
{
|
720 |
+
"epoch": 5.82,
|
721 |
+
"grad_norm": 0.6610634922981262,
|
722 |
+
"learning_rate": 0.0008835616438356165,
|
723 |
+
"loss": 0.3813,
|
724 |
+
"step": 850
|
725 |
+
},
|
726 |
+
{
|
727 |
+
"epoch": 5.89,
|
728 |
+
"grad_norm": 0.9140748977661133,
|
729 |
+
"learning_rate": 0.0008821917808219179,
|
730 |
+
"loss": 0.4658,
|
731 |
+
"step": 860
|
732 |
+
},
|
733 |
+
{
|
734 |
+
"epoch": 5.96,
|
735 |
+
"grad_norm": 0.9210271239280701,
|
736 |
+
"learning_rate": 0.0008808219178082192,
|
737 |
+
"loss": 0.3908,
|
738 |
+
"step": 870
|
739 |
+
},
|
740 |
+
{
|
741 |
+
"epoch": 6.03,
|
742 |
+
"grad_norm": 0.4311777651309967,
|
743 |
+
"learning_rate": 0.0008794520547945207,
|
744 |
+
"loss": 0.4913,
|
745 |
+
"step": 880
|
746 |
+
},
|
747 |
+
{
|
748 |
+
"epoch": 6.1,
|
749 |
+
"grad_norm": 0.6495469212532043,
|
750 |
+
"learning_rate": 0.000878082191780822,
|
751 |
+
"loss": 0.3922,
|
752 |
+
"step": 890
|
753 |
+
},
|
754 |
+
{
|
755 |
+
"epoch": 6.16,
|
756 |
+
"grad_norm": 0.5745411515235901,
|
757 |
+
"learning_rate": 0.0008767123287671232,
|
758 |
+
"loss": 0.3959,
|
759 |
+
"step": 900
|
760 |
+
},
|
761 |
+
{
|
762 |
+
"epoch": 6.16,
|
763 |
+
"eval_accuracy": 0.7645914396887159,
|
764 |
+
"eval_accuracy_class_Bacterial": 0.78125,
|
765 |
+
"eval_accuracy_class_Normal": 0.7642276422764228,
|
766 |
+
"eval_accuracy_class_Viral": 0.7333333333333333,
|
767 |
+
"eval_f1": 0.767354221797679,
|
768 |
+
"eval_loss": 0.8347097635269165,
|
769 |
+
"eval_precision": 0.7748247691701339,
|
770 |
+
"eval_recall": 0.7645914396887159,
|
771 |
+
"eval_runtime": 40.6733,
|
772 |
+
"eval_samples_per_second": 12.637,
|
773 |
+
"eval_steps_per_second": 0.418,
|
774 |
+
"step": 900
|
775 |
+
},
|
776 |
+
{
|
777 |
+
"epoch": 6.23,
|
778 |
+
"grad_norm": 0.3549049496650696,
|
779 |
+
"learning_rate": 0.0008753424657534247,
|
780 |
+
"loss": 0.402,
|
781 |
+
"step": 910
|
782 |
+
},
|
783 |
+
{
|
784 |
+
"epoch": 6.3,
|
785 |
+
"grad_norm": 1.2331146001815796,
|
786 |
+
"learning_rate": 0.000873972602739726,
|
787 |
+
"loss": 0.4013,
|
788 |
+
"step": 920
|
789 |
+
},
|
790 |
+
{
|
791 |
+
"epoch": 6.37,
|
792 |
+
"grad_norm": 0.4287501275539398,
|
793 |
+
"learning_rate": 0.0008726027397260274,
|
794 |
+
"loss": 0.451,
|
795 |
+
"step": 930
|
796 |
+
},
|
797 |
+
{
|
798 |
+
"epoch": 6.44,
|
799 |
+
"grad_norm": 0.30888569355010986,
|
800 |
+
"learning_rate": 0.0008712328767123287,
|
801 |
+
"loss": 0.3853,
|
802 |
+
"step": 940
|
803 |
+
},
|
804 |
+
{
|
805 |
+
"epoch": 6.51,
|
806 |
+
"grad_norm": 0.3006976544857025,
|
807 |
+
"learning_rate": 0.0008698630136986301,
|
808 |
+
"loss": 0.3756,
|
809 |
+
"step": 950
|
810 |
+
},
|
811 |
+
{
|
812 |
+
"epoch": 6.58,
|
813 |
+
"grad_norm": 0.7747860550880432,
|
814 |
+
"learning_rate": 0.0008684931506849315,
|
815 |
+
"loss": 0.472,
|
816 |
+
"step": 960
|
817 |
+
},
|
818 |
+
{
|
819 |
+
"epoch": 6.64,
|
820 |
+
"grad_norm": 0.8170182108879089,
|
821 |
+
"learning_rate": 0.0008671232876712329,
|
822 |
+
"loss": 0.3817,
|
823 |
+
"step": 970
|
824 |
+
},
|
825 |
+
{
|
826 |
+
"epoch": 6.71,
|
827 |
+
"grad_norm": 0.6512866616249084,
|
828 |
+
"learning_rate": 0.0008657534246575342,
|
829 |
+
"loss": 0.4345,
|
830 |
+
"step": 980
|
831 |
+
},
|
832 |
+
{
|
833 |
+
"epoch": 6.78,
|
834 |
+
"grad_norm": 1.3372316360473633,
|
835 |
+
"learning_rate": 0.0008643835616438355,
|
836 |
+
"loss": 0.4163,
|
837 |
+
"step": 990
|
838 |
+
},
|
839 |
+
{
|
840 |
+
"epoch": 6.85,
|
841 |
+
"grad_norm": 0.5636022686958313,
|
842 |
+
"learning_rate": 0.000863013698630137,
|
843 |
+
"loss": 0.3524,
|
844 |
+
"step": 1000
|
845 |
+
},
|
846 |
+
{
|
847 |
+
"epoch": 6.85,
|
848 |
+
"eval_accuracy": 0.7782101167315175,
|
849 |
+
"eval_accuracy_class_Bacterial": 0.83203125,
|
850 |
+
"eval_accuracy_class_Normal": 0.8048780487804879,
|
851 |
+
"eval_accuracy_class_Viral": 0.6518518518518519,
|
852 |
+
"eval_f1": 0.7774953947468894,
|
853 |
+
"eval_loss": 0.8164880871772766,
|
854 |
+
"eval_precision": 0.7802158087533432,
|
855 |
+
"eval_recall": 0.7782101167315175,
|
856 |
+
"eval_runtime": 38.1288,
|
857 |
+
"eval_samples_per_second": 13.481,
|
858 |
+
"eval_steps_per_second": 0.446,
|
859 |
+
"step": 1000
|
860 |
+
},
|
861 |
+
{
|
862 |
+
"epoch": 6.92,
|
863 |
+
"grad_norm": 0.6771811842918396,
|
864 |
+
"learning_rate": 0.0008616438356164383,
|
865 |
+
"loss": 0.3926,
|
866 |
+
"step": 1010
|
867 |
+
},
|
868 |
+
{
|
869 |
+
"epoch": 6.99,
|
870 |
+
"grad_norm": 0.5836020112037659,
|
871 |
+
"learning_rate": 0.0008602739726027397,
|
872 |
+
"loss": 0.4507,
|
873 |
+
"step": 1020
|
874 |
+
},
|
875 |
+
{
|
876 |
+
"epoch": 7.05,
|
877 |
+
"grad_norm": 0.9095780849456787,
|
878 |
+
"learning_rate": 0.000858904109589041,
|
879 |
+
"loss": 0.4257,
|
880 |
+
"step": 1030
|
881 |
+
},
|
882 |
+
{
|
883 |
+
"epoch": 7.12,
|
884 |
+
"grad_norm": 0.735991358757019,
|
885 |
+
"learning_rate": 0.0008575342465753425,
|
886 |
+
"loss": 0.4297,
|
887 |
+
"step": 1040
|
888 |
+
},
|
889 |
+
{
|
890 |
+
"epoch": 7.19,
|
891 |
+
"grad_norm": 0.21994538605213165,
|
892 |
+
"learning_rate": 0.0008561643835616438,
|
893 |
+
"loss": 0.4011,
|
894 |
+
"step": 1050
|
895 |
+
},
|
896 |
+
{
|
897 |
+
"epoch": 7.26,
|
898 |
+
"grad_norm": 0.3590526878833771,
|
899 |
+
"learning_rate": 0.0008547945205479452,
|
900 |
+
"loss": 0.3651,
|
901 |
+
"step": 1060
|
902 |
+
},
|
903 |
+
{
|
904 |
+
"epoch": 7.33,
|
905 |
+
"grad_norm": 1.078801155090332,
|
906 |
+
"learning_rate": 0.0008534246575342465,
|
907 |
+
"loss": 0.4736,
|
908 |
+
"step": 1070
|
909 |
+
},
|
910 |
+
{
|
911 |
+
"epoch": 7.4,
|
912 |
+
"grad_norm": 0.7849373817443848,
|
913 |
+
"learning_rate": 0.000852054794520548,
|
914 |
+
"loss": 0.4423,
|
915 |
+
"step": 1080
|
916 |
+
},
|
917 |
+
{
|
918 |
+
"epoch": 7.47,
|
919 |
+
"grad_norm": 0.43372392654418945,
|
920 |
+
"learning_rate": 0.0008506849315068493,
|
921 |
+
"loss": 0.398,
|
922 |
+
"step": 1090
|
923 |
+
},
|
924 |
+
{
|
925 |
+
"epoch": 7.53,
|
926 |
+
"grad_norm": 0.8436893224716187,
|
927 |
+
"learning_rate": 0.0008493150684931506,
|
928 |
+
"loss": 0.422,
|
929 |
+
"step": 1100
|
930 |
+
},
|
931 |
+
{
|
932 |
+
"epoch": 7.53,
|
933 |
+
"eval_accuracy": 0.7762645914396887,
|
934 |
+
"eval_accuracy_class_Bacterial": 0.86328125,
|
935 |
+
"eval_accuracy_class_Normal": 0.7804878048780488,
|
936 |
+
"eval_accuracy_class_Viral": 0.6074074074074074,
|
937 |
+
"eval_f1": 0.7741563369372261,
|
938 |
+
"eval_loss": 0.7580455541610718,
|
939 |
+
"eval_precision": 0.7825488253813928,
|
940 |
+
"eval_recall": 0.7762645914396887,
|
941 |
+
"eval_runtime": 39.4721,
|
942 |
+
"eval_samples_per_second": 13.022,
|
943 |
+
"eval_steps_per_second": 0.431,
|
944 |
+
"step": 1100
|
945 |
+
},
|
946 |
+
{
|
947 |
+
"epoch": 7.6,
|
948 |
+
"grad_norm": 1.0213713645935059,
|
949 |
+
"learning_rate": 0.000847945205479452,
|
950 |
+
"loss": 0.3556,
|
951 |
+
"step": 1110
|
952 |
+
},
|
953 |
+
{
|
954 |
+
"epoch": 7.67,
|
955 |
+
"grad_norm": 0.45328274369239807,
|
956 |
+
"learning_rate": 0.0008465753424657534,
|
957 |
+
"loss": 0.4054,
|
958 |
+
"step": 1120
|
959 |
+
},
|
960 |
+
{
|
961 |
+
"epoch": 7.74,
|
962 |
+
"grad_norm": 0.28321486711502075,
|
963 |
+
"learning_rate": 0.0008452054794520548,
|
964 |
+
"loss": 0.3806,
|
965 |
+
"step": 1130
|
966 |
+
},
|
967 |
+
{
|
968 |
+
"epoch": 7.81,
|
969 |
+
"grad_norm": 0.9029455184936523,
|
970 |
+
"learning_rate": 0.0008438356164383561,
|
971 |
+
"loss": 0.404,
|
972 |
+
"step": 1140
|
973 |
+
},
|
974 |
+
{
|
975 |
+
"epoch": 7.88,
|
976 |
+
"grad_norm": 0.3433306813240051,
|
977 |
+
"learning_rate": 0.0008424657534246575,
|
978 |
+
"loss": 0.3265,
|
979 |
+
"step": 1150
|
980 |
+
},
|
981 |
+
{
|
982 |
+
"epoch": 7.95,
|
983 |
+
"grad_norm": 0.9373074769973755,
|
984 |
+
"learning_rate": 0.0008410958904109589,
|
985 |
+
"loss": 0.4464,
|
986 |
+
"step": 1160
|
987 |
+
},
|
988 |
+
{
|
989 |
+
"epoch": 8.01,
|
990 |
+
"grad_norm": 0.5745645761489868,
|
991 |
+
"learning_rate": 0.0008397260273972603,
|
992 |
+
"loss": 0.4057,
|
993 |
+
"step": 1170
|
994 |
+
},
|
995 |
+
{
|
996 |
+
"epoch": 8.08,
|
997 |
+
"grad_norm": 0.38959360122680664,
|
998 |
+
"learning_rate": 0.0008383561643835616,
|
999 |
+
"loss": 0.3368,
|
1000 |
+
"step": 1180
|
1001 |
+
},
|
1002 |
+
{
|
1003 |
+
"epoch": 8.15,
|
1004 |
+
"grad_norm": 0.3645295202732086,
|
1005 |
+
"learning_rate": 0.0008369863013698629,
|
1006 |
+
"loss": 0.4245,
|
1007 |
+
"step": 1190
|
1008 |
+
},
|
1009 |
+
{
|
1010 |
+
"epoch": 8.22,
|
1011 |
+
"grad_norm": 0.8835442066192627,
|
1012 |
+
"learning_rate": 0.0008356164383561644,
|
1013 |
+
"loss": 0.4398,
|
1014 |
+
"step": 1200
|
1015 |
+
},
|
1016 |
+
{
|
1017 |
+
"epoch": 8.22,
|
1018 |
+
"eval_accuracy": 0.7276264591439688,
|
1019 |
+
"eval_accuracy_class_Bacterial": 0.69140625,
|
1020 |
+
"eval_accuracy_class_Normal": 0.8048780487804879,
|
1021 |
+
"eval_accuracy_class_Viral": 0.725925925925926,
|
1022 |
+
"eval_f1": 0.7303442580310747,
|
1023 |
+
"eval_loss": 0.8645263910293579,
|
1024 |
+
"eval_precision": 0.7390963461212989,
|
1025 |
+
"eval_recall": 0.7276264591439688,
|
1026 |
+
"eval_runtime": 88.6089,
|
1027 |
+
"eval_samples_per_second": 5.801,
|
1028 |
+
"eval_steps_per_second": 0.192,
|
1029 |
+
"step": 1200
|
1030 |
+
},
|
1031 |
+
{
|
1032 |
+
"epoch": 8.29,
|
1033 |
+
"grad_norm": 0.235728457570076,
|
1034 |
+
"learning_rate": 0.0008342465753424657,
|
1035 |
+
"loss": 0.4229,
|
1036 |
+
"step": 1210
|
1037 |
+
},
|
1038 |
+
{
|
1039 |
+
"epoch": 8.36,
|
1040 |
+
"grad_norm": 0.9462645053863525,
|
1041 |
+
"learning_rate": 0.0008328767123287671,
|
1042 |
+
"loss": 0.3902,
|
1043 |
+
"step": 1220
|
1044 |
+
},
|
1045 |
+
{
|
1046 |
+
"epoch": 8.42,
|
1047 |
+
"grad_norm": 0.3837108910083771,
|
1048 |
+
"learning_rate": 0.0008315068493150684,
|
1049 |
+
"loss": 0.4508,
|
1050 |
+
"step": 1230
|
1051 |
+
},
|
1052 |
+
{
|
1053 |
+
"epoch": 8.49,
|
1054 |
+
"grad_norm": 0.5294187068939209,
|
1055 |
+
"learning_rate": 0.0008301369863013699,
|
1056 |
+
"loss": 0.3643,
|
1057 |
+
"step": 1240
|
1058 |
+
},
|
1059 |
+
{
|
1060 |
+
"epoch": 8.56,
|
1061 |
+
"grad_norm": 0.4534919261932373,
|
1062 |
+
"learning_rate": 0.0008287671232876712,
|
1063 |
+
"loss": 0.4308,
|
1064 |
+
"step": 1250
|
1065 |
+
},
|
1066 |
+
{
|
1067 |
+
"epoch": 8.63,
|
1068 |
+
"grad_norm": 0.5512118935585022,
|
1069 |
+
"learning_rate": 0.0008273972602739726,
|
1070 |
+
"loss": 0.3734,
|
1071 |
+
"step": 1260
|
1072 |
+
},
|
1073 |
+
{
|
1074 |
+
"epoch": 8.7,
|
1075 |
+
"grad_norm": 0.446801096200943,
|
1076 |
+
"learning_rate": 0.000826027397260274,
|
1077 |
+
"loss": 0.3612,
|
1078 |
+
"step": 1270
|
1079 |
+
},
|
1080 |
+
{
|
1081 |
+
"epoch": 8.77,
|
1082 |
+
"grad_norm": 1.0712846517562866,
|
1083 |
+
"learning_rate": 0.0008246575342465754,
|
1084 |
+
"loss": 0.361,
|
1085 |
+
"step": 1280
|
1086 |
+
},
|
1087 |
+
{
|
1088 |
+
"epoch": 8.84,
|
1089 |
+
"grad_norm": 1.1732456684112549,
|
1090 |
+
"learning_rate": 0.0008232876712328767,
|
1091 |
+
"loss": 0.3792,
|
1092 |
+
"step": 1290
|
1093 |
+
},
|
1094 |
+
{
|
1095 |
+
"epoch": 8.9,
|
1096 |
+
"grad_norm": 0.5159270167350769,
|
1097 |
+
"learning_rate": 0.000821917808219178,
|
1098 |
+
"loss": 0.3962,
|
1099 |
+
"step": 1300
|
1100 |
+
},
|
1101 |
+
{
|
1102 |
+
"epoch": 8.9,
|
1103 |
+
"eval_accuracy": 0.754863813229572,
|
1104 |
+
"eval_accuracy_class_Bacterial": 0.74609375,
|
1105 |
+
"eval_accuracy_class_Normal": 0.8048780487804879,
|
1106 |
+
"eval_accuracy_class_Viral": 0.725925925925926,
|
1107 |
+
"eval_f1": 0.7560885847797696,
|
1108 |
+
"eval_loss": 0.8278017640113831,
|
1109 |
+
"eval_precision": 0.7588608378059307,
|
1110 |
+
"eval_recall": 0.754863813229572,
|
1111 |
+
"eval_runtime": 476.7256,
|
1112 |
+
"eval_samples_per_second": 1.078,
|
1113 |
+
"eval_steps_per_second": 0.036,
|
1114 |
+
"step": 1300
|
1115 |
+
},
|
1116 |
+
{
|
1117 |
+
"epoch": 8.97,
|
1118 |
+
"grad_norm": 0.48536455631256104,
|
1119 |
+
"learning_rate": 0.0008205479452054795,
|
1120 |
+
"loss": 0.4093,
|
1121 |
+
"step": 1310
|
1122 |
+
},
|
1123 |
+
{
|
1124 |
+
"epoch": 9.04,
|
1125 |
+
"grad_norm": 0.9068573117256165,
|
1126 |
+
"learning_rate": 0.0008191780821917808,
|
1127 |
+
"loss": 0.47,
|
1128 |
+
"step": 1320
|
1129 |
+
},
|
1130 |
+
{
|
1131 |
+
"epoch": 9.11,
|
1132 |
+
"grad_norm": 0.3649793863296509,
|
1133 |
+
"learning_rate": 0.0008178082191780822,
|
1134 |
+
"loss": 0.3298,
|
1135 |
+
"step": 1330
|
1136 |
+
},
|
1137 |
+
{
|
1138 |
+
"epoch": 9.18,
|
1139 |
+
"grad_norm": 0.5880826711654663,
|
1140 |
+
"learning_rate": 0.0008164383561643835,
|
1141 |
+
"loss": 0.3088,
|
1142 |
+
"step": 1340
|
1143 |
+
},
|
1144 |
+
{
|
1145 |
+
"epoch": 9.25,
|
1146 |
+
"grad_norm": 0.9857625365257263,
|
1147 |
+
"learning_rate": 0.000815068493150685,
|
1148 |
+
"loss": 0.3509,
|
1149 |
+
"step": 1350
|
1150 |
+
},
|
1151 |
+
{
|
1152 |
+
"epoch": 9.32,
|
1153 |
+
"grad_norm": 1.4002394676208496,
|
1154 |
+
"learning_rate": 0.0008136986301369863,
|
1155 |
+
"loss": 0.4272,
|
1156 |
+
"step": 1360
|
1157 |
+
},
|
1158 |
+
{
|
1159 |
+
"epoch": 9.38,
|
1160 |
+
"grad_norm": 0.28744077682495117,
|
1161 |
+
"learning_rate": 0.0008123287671232877,
|
1162 |
+
"loss": 0.4068,
|
1163 |
+
"step": 1370
|
1164 |
+
},
|
1165 |
+
{
|
1166 |
+
"epoch": 9.45,
|
1167 |
+
"grad_norm": 0.3996258080005646,
|
1168 |
+
"learning_rate": 0.000810958904109589,
|
1169 |
+
"loss": 0.339,
|
1170 |
+
"step": 1380
|
1171 |
+
},
|
1172 |
+
{
|
1173 |
+
"epoch": 9.52,
|
1174 |
+
"grad_norm": 0.9040880799293518,
|
1175 |
+
"learning_rate": 0.0008095890410958904,
|
1176 |
+
"loss": 0.3977,
|
1177 |
+
"step": 1390
|
1178 |
+
},
|
1179 |
+
{
|
1180 |
+
"epoch": 9.59,
|
1181 |
+
"grad_norm": 0.965135931968689,
|
1182 |
+
"learning_rate": 0.0008082191780821918,
|
1183 |
+
"loss": 0.3871,
|
1184 |
+
"step": 1400
|
1185 |
+
},
|
1186 |
+
{
|
1187 |
+
"epoch": 9.59,
|
1188 |
+
"eval_accuracy": 0.7607003891050583,
|
1189 |
+
"eval_accuracy_class_Bacterial": 0.73828125,
|
1190 |
+
"eval_accuracy_class_Normal": 0.7723577235772358,
|
1191 |
+
"eval_accuracy_class_Viral": 0.7925925925925926,
|
1192 |
+
"eval_f1": 0.7650308027920366,
|
1193 |
+
"eval_loss": 0.8378809094429016,
|
1194 |
+
"eval_precision": 0.7797474302208566,
|
1195 |
+
"eval_recall": 0.7607003891050583,
|
1196 |
+
"eval_runtime": 24.5865,
|
1197 |
+
"eval_samples_per_second": 20.906,
|
1198 |
+
"eval_steps_per_second": 0.691,
|
1199 |
+
"step": 1400
|
1200 |
+
},
|
1201 |
+
{
|
1202 |
+
"epoch": 9.66,
|
1203 |
+
"grad_norm": 0.6330709457397461,
|
1204 |
+
"learning_rate": 0.0008068493150684931,
|
1205 |
+
"loss": 0.3691,
|
1206 |
+
"step": 1410
|
1207 |
+
},
|
1208 |
+
{
|
1209 |
+
"epoch": 9.73,
|
1210 |
+
"grad_norm": 0.1988159418106079,
|
1211 |
+
"learning_rate": 0.0008054794520547945,
|
1212 |
+
"loss": 0.3915,
|
1213 |
+
"step": 1420
|
1214 |
+
},
|
1215 |
+
{
|
1216 |
+
"epoch": 9.79,
|
1217 |
+
"grad_norm": 0.35764390230178833,
|
1218 |
+
"learning_rate": 0.0008041095890410959,
|
1219 |
+
"loss": 0.4255,
|
1220 |
+
"step": 1430
|
1221 |
+
},
|
1222 |
+
{
|
1223 |
+
"epoch": 9.86,
|
1224 |
+
"grad_norm": 0.5993324518203735,
|
1225 |
+
"learning_rate": 0.0008027397260273973,
|
1226 |
+
"loss": 0.3154,
|
1227 |
+
"step": 1440
|
1228 |
+
},
|
1229 |
+
{
|
1230 |
+
"epoch": 9.93,
|
1231 |
+
"grad_norm": 0.6987205147743225,
|
1232 |
+
"learning_rate": 0.0008013698630136986,
|
1233 |
+
"loss": 0.4347,
|
1234 |
+
"step": 1450
|
1235 |
+
},
|
1236 |
+
{
|
1237 |
+
"epoch": 10.0,
|
1238 |
+
"grad_norm": 1.6289706230163574,
|
1239 |
+
"learning_rate": 0.0008,
|
1240 |
+
"loss": 0.5012,
|
1241 |
+
"step": 1460
|
1242 |
+
},
|
1243 |
+
{
|
1244 |
+
"epoch": 10.07,
|
1245 |
+
"grad_norm": 0.42524194717407227,
|
1246 |
+
"learning_rate": 0.0007986301369863014,
|
1247 |
+
"loss": 0.3247,
|
1248 |
+
"step": 1470
|
1249 |
+
},
|
1250 |
+
{
|
1251 |
+
"epoch": 10.14,
|
1252 |
+
"grad_norm": 0.45430487394332886,
|
1253 |
+
"learning_rate": 0.0007972602739726027,
|
1254 |
+
"loss": 0.3774,
|
1255 |
+
"step": 1480
|
1256 |
+
},
|
1257 |
+
{
|
1258 |
+
"epoch": 10.21,
|
1259 |
+
"grad_norm": 0.4011427164077759,
|
1260 |
+
"learning_rate": 0.0007958904109589041,
|
1261 |
+
"loss": 0.3483,
|
1262 |
+
"step": 1490
|
1263 |
+
},
|
1264 |
+
{
|
1265 |
+
"epoch": 10.27,
|
1266 |
+
"grad_norm": 1.9553821086883545,
|
1267 |
+
"learning_rate": 0.0007945205479452054,
|
1268 |
+
"loss": 0.3949,
|
1269 |
+
"step": 1500
|
1270 |
+
},
|
1271 |
+
{
|
1272 |
+
"epoch": 10.27,
|
1273 |
+
"eval_accuracy": 0.7704280155642024,
|
1274 |
+
"eval_accuracy_class_Bacterial": 0.76171875,
|
1275 |
+
"eval_accuracy_class_Normal": 0.7967479674796748,
|
1276 |
+
"eval_accuracy_class_Viral": 0.762962962962963,
|
1277 |
+
"eval_f1": 0.7727560365613958,
|
1278 |
+
"eval_loss": 0.8412158489227295,
|
1279 |
+
"eval_precision": 0.7787042029583747,
|
1280 |
+
"eval_recall": 0.7704280155642024,
|
1281 |
+
"eval_runtime": 26.6938,
|
1282 |
+
"eval_samples_per_second": 19.255,
|
1283 |
+
"eval_steps_per_second": 0.637,
|
1284 |
+
"step": 1500
|
1285 |
+
},
|
1286 |
+
{
|
1287 |
+
"epoch": 10.34,
|
1288 |
+
"grad_norm": 0.5882077217102051,
|
1289 |
+
"learning_rate": 0.0007931506849315069,
|
1290 |
+
"loss": 0.4126,
|
1291 |
+
"step": 1510
|
1292 |
+
},
|
1293 |
+
{
|
1294 |
+
"epoch": 10.41,
|
1295 |
+
"grad_norm": 1.9042034149169922,
|
1296 |
+
"learning_rate": 0.0007917808219178082,
|
1297 |
+
"loss": 0.4275,
|
1298 |
+
"step": 1520
|
1299 |
+
},
|
1300 |
+
{
|
1301 |
+
"epoch": 10.48,
|
1302 |
+
"grad_norm": 0.38827410340309143,
|
1303 |
+
"learning_rate": 0.0007904109589041096,
|
1304 |
+
"loss": 0.4241,
|
1305 |
+
"step": 1530
|
1306 |
+
},
|
1307 |
+
{
|
1308 |
+
"epoch": 10.55,
|
1309 |
+
"grad_norm": 1.0685482025146484,
|
1310 |
+
"learning_rate": 0.0007890410958904109,
|
1311 |
+
"loss": 0.3723,
|
1312 |
+
"step": 1540
|
1313 |
+
},
|
1314 |
+
{
|
1315 |
+
"epoch": 10.62,
|
1316 |
+
"grad_norm": 0.4978479743003845,
|
1317 |
+
"learning_rate": 0.0007876712328767124,
|
1318 |
+
"loss": 0.4213,
|
1319 |
+
"step": 1550
|
1320 |
+
},
|
1321 |
+
{
|
1322 |
+
"epoch": 10.68,
|
1323 |
+
"grad_norm": 0.5836212635040283,
|
1324 |
+
"learning_rate": 0.0007863013698630137,
|
1325 |
+
"loss": 0.3702,
|
1326 |
+
"step": 1560
|
1327 |
+
},
|
1328 |
+
{
|
1329 |
+
"epoch": 10.75,
|
1330 |
+
"grad_norm": 0.7332190871238708,
|
1331 |
+
"learning_rate": 0.0007849315068493151,
|
1332 |
+
"loss": 0.3701,
|
1333 |
+
"step": 1570
|
1334 |
+
},
|
1335 |
+
{
|
1336 |
+
"epoch": 10.82,
|
1337 |
+
"grad_norm": 0.6048933267593384,
|
1338 |
+
"learning_rate": 0.0007835616438356164,
|
1339 |
+
"loss": 0.4229,
|
1340 |
+
"step": 1580
|
1341 |
+
},
|
1342 |
+
{
|
1343 |
+
"epoch": 10.89,
|
1344 |
+
"grad_norm": 0.8896064162254333,
|
1345 |
+
"learning_rate": 0.0007821917808219178,
|
1346 |
+
"loss": 0.3429,
|
1347 |
+
"step": 1590
|
1348 |
+
},
|
1349 |
+
{
|
1350 |
+
"epoch": 10.96,
|
1351 |
+
"grad_norm": 0.3327595591545105,
|
1352 |
+
"learning_rate": 0.0007808219178082192,
|
1353 |
+
"loss": 0.3547,
|
1354 |
+
"step": 1600
|
1355 |
+
},
|
1356 |
+
{
|
1357 |
+
"epoch": 10.96,
|
1358 |
+
"eval_accuracy": 0.7645914396887159,
|
1359 |
+
"eval_accuracy_class_Bacterial": 0.7265625,
|
1360 |
+
"eval_accuracy_class_Normal": 0.7967479674796748,
|
1361 |
+
"eval_accuracy_class_Viral": 0.8074074074074075,
|
1362 |
+
"eval_f1": 0.7688402503119753,
|
1363 |
+
"eval_loss": 0.8228224515914917,
|
1364 |
+
"eval_precision": 0.7840447085340081,
|
1365 |
+
"eval_recall": 0.7645914396887159,
|
1366 |
+
"eval_runtime": 25.0146,
|
1367 |
+
"eval_samples_per_second": 20.548,
|
1368 |
+
"eval_steps_per_second": 0.68,
|
1369 |
+
"step": 1600
|
1370 |
+
},
|
1371 |
+
{
|
1372 |
+
"epoch": 11.03,
|
1373 |
+
"grad_norm": 1.2333165407180786,
|
1374 |
+
"learning_rate": 0.0007794520547945205,
|
1375 |
+
"loss": 0.2956,
|
1376 |
+
"step": 1610
|
1377 |
+
},
|
1378 |
+
{
|
1379 |
+
"epoch": 11.1,
|
1380 |
+
"grad_norm": 0.970270037651062,
|
1381 |
+
"learning_rate": 0.0007780821917808219,
|
1382 |
+
"loss": 0.4526,
|
1383 |
+
"step": 1620
|
1384 |
+
},
|
1385 |
+
{
|
1386 |
+
"epoch": 11.16,
|
1387 |
+
"grad_norm": 0.8335412740707397,
|
1388 |
+
"learning_rate": 0.0007767123287671233,
|
1389 |
+
"loss": 0.4005,
|
1390 |
+
"step": 1630
|
1391 |
+
},
|
1392 |
+
{
|
1393 |
+
"epoch": 11.23,
|
1394 |
+
"grad_norm": 0.5635302662849426,
|
1395 |
+
"learning_rate": 0.0007753424657534247,
|
1396 |
+
"loss": 0.3713,
|
1397 |
+
"step": 1640
|
1398 |
+
},
|
1399 |
+
{
|
1400 |
+
"epoch": 11.3,
|
1401 |
+
"grad_norm": 0.555288553237915,
|
1402 |
+
"learning_rate": 0.000773972602739726,
|
1403 |
+
"loss": 0.4158,
|
1404 |
+
"step": 1650
|
1405 |
+
},
|
1406 |
+
{
|
1407 |
+
"epoch": 11.37,
|
1408 |
+
"grad_norm": 0.8734630346298218,
|
1409 |
+
"learning_rate": 0.0007726027397260274,
|
1410 |
+
"loss": 0.3844,
|
1411 |
+
"step": 1660
|
1412 |
+
},
|
1413 |
+
{
|
1414 |
+
"epoch": 11.44,
|
1415 |
+
"grad_norm": 1.3194448947906494,
|
1416 |
+
"learning_rate": 0.0007712328767123288,
|
1417 |
+
"loss": 0.3602,
|
1418 |
+
"step": 1670
|
1419 |
+
},
|
1420 |
+
{
|
1421 |
+
"epoch": 11.51,
|
1422 |
+
"grad_norm": 0.9547590613365173,
|
1423 |
+
"learning_rate": 0.0007698630136986301,
|
1424 |
+
"loss": 0.3285,
|
1425 |
+
"step": 1680
|
1426 |
+
},
|
1427 |
+
{
|
1428 |
+
"epoch": 11.58,
|
1429 |
+
"grad_norm": 0.9226530194282532,
|
1430 |
+
"learning_rate": 0.0007684931506849315,
|
1431 |
+
"loss": 0.3075,
|
1432 |
+
"step": 1690
|
1433 |
+
},
|
1434 |
+
{
|
1435 |
+
"epoch": 11.64,
|
1436 |
+
"grad_norm": 0.3840011656284332,
|
1437 |
+
"learning_rate": 0.0007671232876712328,
|
1438 |
+
"loss": 0.3994,
|
1439 |
+
"step": 1700
|
1440 |
+
},
|
1441 |
+
{
|
1442 |
+
"epoch": 11.64,
|
1443 |
+
"eval_accuracy": 0.77431906614786,
|
1444 |
+
"eval_accuracy_class_Bacterial": 0.7890625,
|
1445 |
+
"eval_accuracy_class_Normal": 0.7886178861788617,
|
1446 |
+
"eval_accuracy_class_Viral": 0.7333333333333333,
|
1447 |
+
"eval_f1": 0.7774772964245277,
|
1448 |
+
"eval_loss": 0.8398252129554749,
|
1449 |
+
"eval_precision": 0.7855846838648818,
|
1450 |
+
"eval_recall": 0.77431906614786,
|
1451 |
+
"eval_runtime": 26.6906,
|
1452 |
+
"eval_samples_per_second": 19.258,
|
1453 |
+
"eval_steps_per_second": 0.637,
|
1454 |
+
"step": 1700
|
1455 |
+
},
|
1456 |
+
{
|
1457 |
+
"epoch": 11.71,
|
1458 |
+
"grad_norm": 0.4347558617591858,
|
1459 |
+
"learning_rate": 0.0007657534246575343,
|
1460 |
+
"loss": 0.3146,
|
1461 |
+
"step": 1710
|
1462 |
+
},
|
1463 |
+
{
|
1464 |
+
"epoch": 11.78,
|
1465 |
+
"grad_norm": 0.5778964757919312,
|
1466 |
+
"learning_rate": 0.0007643835616438356,
|
1467 |
+
"loss": 0.3872,
|
1468 |
+
"step": 1720
|
1469 |
+
},
|
1470 |
+
{
|
1471 |
+
"epoch": 11.85,
|
1472 |
+
"grad_norm": 0.7429023385047913,
|
1473 |
+
"learning_rate": 0.000763013698630137,
|
1474 |
+
"loss": 0.3561,
|
1475 |
+
"step": 1730
|
1476 |
+
},
|
1477 |
+
{
|
1478 |
+
"epoch": 11.92,
|
1479 |
+
"grad_norm": 0.938795268535614,
|
1480 |
+
"learning_rate": 0.0007616438356164383,
|
1481 |
+
"loss": 0.4158,
|
1482 |
+
"step": 1740
|
1483 |
+
},
|
1484 |
+
{
|
1485 |
+
"epoch": 11.99,
|
1486 |
+
"grad_norm": 0.4394015967845917,
|
1487 |
+
"learning_rate": 0.0007602739726027398,
|
1488 |
+
"loss": 0.3729,
|
1489 |
+
"step": 1750
|
1490 |
+
},
|
1491 |
+
{
|
1492 |
+
"epoch": 12.05,
|
1493 |
+
"grad_norm": 0.6519060134887695,
|
1494 |
+
"learning_rate": 0.0007589041095890411,
|
1495 |
+
"loss": 0.3371,
|
1496 |
+
"step": 1760
|
1497 |
+
},
|
1498 |
+
{
|
1499 |
+
"epoch": 12.12,
|
1500 |
+
"grad_norm": 0.3657008707523346,
|
1501 |
+
"learning_rate": 0.0007575342465753425,
|
1502 |
+
"loss": 0.3517,
|
1503 |
+
"step": 1770
|
1504 |
+
},
|
1505 |
+
{
|
1506 |
+
"epoch": 12.19,
|
1507 |
+
"grad_norm": 0.4903722107410431,
|
1508 |
+
"learning_rate": 0.0007561643835616439,
|
1509 |
+
"loss": 0.3818,
|
1510 |
+
"step": 1780
|
1511 |
+
},
|
1512 |
+
{
|
1513 |
+
"epoch": 12.26,
|
1514 |
+
"grad_norm": 0.41789180040359497,
|
1515 |
+
"learning_rate": 0.0007547945205479452,
|
1516 |
+
"loss": 0.3878,
|
1517 |
+
"step": 1790
|
1518 |
+
},
|
1519 |
+
{
|
1520 |
+
"epoch": 12.33,
|
1521 |
+
"grad_norm": 0.6251237392425537,
|
1522 |
+
"learning_rate": 0.0007534246575342466,
|
1523 |
+
"loss": 0.3717,
|
1524 |
+
"step": 1800
|
1525 |
+
},
|
1526 |
+
{
|
1527 |
+
"epoch": 12.33,
|
1528 |
+
"eval_accuracy": 0.7704280155642024,
|
1529 |
+
"eval_accuracy_class_Bacterial": 0.78515625,
|
1530 |
+
"eval_accuracy_class_Normal": 0.8048780487804879,
|
1531 |
+
"eval_accuracy_class_Viral": 0.7111111111111111,
|
1532 |
+
"eval_f1": 0.7718021949322796,
|
1533 |
+
"eval_loss": 0.7440524101257324,
|
1534 |
+
"eval_precision": 0.774278133812427,
|
1535 |
+
"eval_recall": 0.7704280155642024,
|
1536 |
+
"eval_runtime": 26.5014,
|
1537 |
+
"eval_samples_per_second": 19.395,
|
1538 |
+
"eval_steps_per_second": 0.641,
|
1539 |
+
"step": 1800
|
1540 |
+
}
|
1541 |
+
],
|
1542 |
+
"logging_steps": 10,
|
1543 |
+
"max_steps": 7300,
|
1544 |
+
"num_input_tokens_seen": 0,
|
1545 |
+
"num_train_epochs": 50,
|
1546 |
+
"save_steps": 100,
|
1547 |
+
"total_flos": 4.439400889630114e+18,
|
1548 |
+
"train_batch_size": 32,
|
1549 |
+
"trial_name": null,
|
1550 |
+
"trial_params": null
|
1551 |
+
}
|
models/training_args.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:9d6c11078065b9bfd3a041f71cbf2e838578aa9ab78caac1121bbc0b2e39bf16
|
3 |
+
size 4920
|