'neural'
6
ai-wozek/.idea/.gitignore
vendored
@ -1,3 +1,3 @@
|
|||||||
# Default ignored files
|
# Default ignored files
|
||||||
/shelf/
|
/shelf/
|
||||||
/workspace.xml
|
/workspace.xml
|
||||||
|
11
ai-wozek/.idea/aws.xml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="accountSettings">
|
||||||
|
<option name="activeRegion" value="us-east-1" />
|
||||||
|
<option name="recentlyUsedRegions">
|
||||||
|
<list>
|
||||||
|
<option value="us-east-1" />
|
||||||
|
</list>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
7
ai-wozek/.idea/misc.xml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="Black">
|
||||||
|
<option name="sdkName" value="Python 3.11 (ai-wozek) (2)" />
|
||||||
|
</component>
|
||||||
|
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11 (ai-wozek) (2)" project-jdk-type="Python SDK" />
|
||||||
|
</project>
|
@ -1,8 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ProjectModuleManager">
|
<component name="ProjectModuleManager">
|
||||||
<modules>
|
<modules>
|
||||||
<module fileurl="file://$PROJECT_DIR$/.idea/wozek.iml" filepath="$PROJECT_DIR$/.idea/wozek.iml" />
|
<module fileurl="file://$PROJECT_DIR$/.idea/wozek.iml" filepath="$PROJECT_DIR$/.idea/wozek.iml" />
|
||||||
</modules>
|
</modules>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
@ -1,18 +1,24 @@
|
|||||||
<component name="ProjectRunConfigurationManager">
|
<component name="ProjectRunConfigurationManager">
|
||||||
<configuration default="false" name="wozek" type="PythonConfigurationType" factoryName="Python" nameIsGenerated="true">
|
<configuration default="false" name="wozek" type="PythonConfigurationType" factoryName="Python" nameIsGenerated="true">
|
||||||
<module name="wozek" />
|
<module name="wozek" />
|
||||||
|
<option name="ENV_FILES" value="" />
|
||||||
<option name="INTERPRETER_OPTIONS" value="" />
|
<option name="INTERPRETER_OPTIONS" value="" />
|
||||||
<option name="PARENT_ENVS" value="true" />
|
<option name="PARENT_ENVS" value="true" />
|
||||||
<envs>
|
<envs>
|
||||||
<env name="PYTHONUNBUFFERED" value="1" />
|
<env name="PYTHONUNBUFFERED" value="1" />
|
||||||
</envs>
|
</envs>
|
||||||
<option name="SDK_HOME" value="" />
|
<option name="SDK_HOME" value="" />
|
||||||
<option name="SDK_NAME" value="Python 3.10" />
|
<option name="SDK_NAME" value="Python 3.11 (ai-wozek) (2)" />
|
||||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
|
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
|
||||||
<option name="IS_MODULE_SDK" value="false" />
|
<option name="IS_MODULE_SDK" value="false" />
|
||||||
<option name="ADD_CONTENT_ROOTS" value="true" />
|
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||||
<option name="ADD_SOURCE_ROOTS" value="true" />
|
<option name="ADD_SOURCE_ROOTS" value="true" />
|
||||||
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
|
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
|
||||||
|
<EXTENSION ID="software.aws.toolkits.jetbrains.core.execution.PythonAwsConnectionExtension">
|
||||||
|
<option name="credential" />
|
||||||
|
<option name="region" />
|
||||||
|
<option name="useCurrentConnection" value="false" />
|
||||||
|
</EXTENSION>
|
||||||
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/wozek.py" />
|
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/wozek.py" />
|
||||||
<option name="PARAMETERS" value="" />
|
<option name="PARAMETERS" value="" />
|
||||||
<option name="SHOW_COMMAND_LINE" value="false" />
|
<option name="SHOW_COMMAND_LINE" value="false" />
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<module type="PYTHON_MODULE" version="4">
|
<module type="PYTHON_MODULE" version="4">
|
||||||
<component name="NewModuleRootManager">
|
<component name="NewModuleRootManager">
|
||||||
<content url="file://$MODULE_DIR$" />
|
<content url="file://$MODULE_DIR$">
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<excludeFolder url="file://$MODULE_DIR$/venv" />
|
||||||
</component>
|
</content>
|
||||||
|
<orderEntry type="jdk" jdkName="Python 3.11 (ai-wozek) (2)" jdkType="Python SDK" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
</module>
|
</module>
|
1
ai-wozek/.~lock.paczki.csv#
Normal file
@ -0,0 +1 @@
|
|||||||
|
,DESKTOP-REF7T1M/abc,DESKTOP-REF7T1M,16.06.2024 22:58,file:///C:/Users/abc/AppData/Roaming/LibreOffice/4;
|
@ -1,4 +1,4 @@
|
|||||||
[ZoneTransfer]
|
[ZoneTransfer]
|
||||||
ZoneId=3
|
ZoneId=3
|
||||||
ReferrerUrl=https://cloudconvert.com/
|
ReferrerUrl=https://cloudconvert.com/
|
||||||
HostUrl=https://eu-central.storage.cloudconvert.com/tasks/89fd002d-da8d-428b-8ab9-f34e46a152d2/car_parts.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=cloudconvert-production%2F20240313%2Ffra%2Fs3%2Faws4_request&X-Amz-Date=20240313T125446Z&X-Amz-Expires=86400&X-Amz-Signature=5a6c7c1a4a9ace4b9847c1333519558594ff9acf8eef806f38e598003f86ffca&X-Amz-SignedHeaders=host&response-content-disposition=attachment%3B%20filename%3D%22car_parts.png%22&response-content-type=image%2Fpng&x-id=GetObject
|
HostUrl=https://eu-central.storage.cloudconvert.com/tasks/89fd002d-da8d-428b-8ab9-f34e46a152d2/car_parts.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=cloudconvert-production%2F20240313%2Ffra%2Fs3%2Faws4_request&X-Amz-Date=20240313T125446Z&X-Amz-Expires=86400&X-Amz-Signature=5a6c7c1a4a9ace4b9847c1333519558594ff9acf8eef806f38e598003f86ffca&X-Amz-SignedHeaders=host&response-content-disposition=attachment%3B%20filename%3D%22car_parts.png%22&response-content-type=image%2Fpng&x-id=GetObject
|
||||||
|
0
ai-wozek/cargo.py
Normal file
@ -1,12 +1,31 @@
|
|||||||
|
import random
|
||||||
|
from glob import glob
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
class Cargo:
|
class Cargo:
|
||||||
def __init__(self, name, category, size, weight):
|
def __init__(self, height,width,depth,weight,damage,label_state,content,value,position):
|
||||||
self.name = name
|
self.height=height
|
||||||
self.size = size
|
self.width=width
|
||||||
self.weight = weight
|
self.depth=depth
|
||||||
self.category = category
|
self.weight=weight
|
||||||
|
self.damage=damage
|
||||||
|
self.label_state=label_state
|
||||||
|
self.content=content
|
||||||
|
self.value=value
|
||||||
|
self.position=position
|
||||||
|
def contentSplit(self):
|
||||||
|
if self.content=='fruits':
|
||||||
|
test=glob('./siec/train/fragile/*')
|
||||||
|
self.image=np.random.choice(test)
|
||||||
|
elif self.content=='nuclear_waste':
|
||||||
|
test=glob('./siec/train/toxic/*')
|
||||||
|
self.image = np.random.choice(test)
|
||||||
|
elif self.content=='clothes':
|
||||||
|
test = glob('./siec/train/flammable/*')
|
||||||
|
self.image = np.random.choice(test)
|
||||||
|
else:
|
||||||
|
self.image='./fruit.png'
|
||||||
|
print(self.image)
|
||||||
|
|
||||||
class Clothes(Cargo):
|
class Clothes(Cargo):
|
||||||
def __init__(self, name, size, weight, fragility):
|
def __init__(self, name, size, weight, fragility):
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
[ZoneTransfer]
|
[ZoneTransfer]
|
||||||
ZoneId=3
|
ZoneId=3
|
||||||
ReferrerUrl=https://cloudconvert.com/
|
ReferrerUrl=https://cloudconvert.com/
|
||||||
HostUrl=https://eu-central.storage.cloudconvert.com/tasks/bed19f02-21bb-4af5-9a42-7cc3365f2bf4/clothes.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=cloudconvert-production%2F20240313%2Ffra%2Fs3%2Faws4_request&X-Amz-Date=20240313T125445Z&X-Amz-Expires=86400&X-Amz-Signature=f4586482e9493741e4b8acf756f10e3f879fc503bf0f4d05c1d4131aee65006a&X-Amz-SignedHeaders=host&response-content-disposition=attachment%3B%20filename%3D%22clothes.png%22&response-content-type=image%2Fpng&x-id=GetObject
|
HostUrl=https://eu-central.storage.cloudconvert.com/tasks/bed19f02-21bb-4af5-9a42-7cc3365f2bf4/clothes.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=cloudconvert-production%2F20240313%2Ffra%2Fs3%2Faws4_request&X-Amz-Date=20240313T125445Z&X-Amz-Expires=86400&X-Amz-Signature=f4586482e9493741e4b8acf756f10e3f879fc503bf0f4d05c1d4131aee65006a&X-Amz-SignedHeaders=host&response-content-disposition=attachment%3B%20filename%3D%22clothes.png%22&response-content-type=image%2Fpng&x-id=GetObject
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
[ZoneTransfer]
|
[ZoneTransfer]
|
||||||
ZoneId=3
|
ZoneId=3
|
||||||
ReferrerUrl=https://cloudconvert.com/
|
ReferrerUrl=https://cloudconvert.com/
|
||||||
HostUrl=https://eu-central.storage.cloudconvert.com/tasks/72d14743-46c1-4131-ad52-b8c020251781/DALL%C2%B7E%202024-03-13%2013.49.29%20-%20A%20cute%2C%20cartoonish%20forklift%20in%20a%20simple%2C%20colorful%20style%2C%20isolated%20on%20a%20white%20background%2C%20suitable%20for%20a%2032x32%20pixels%20square%20format.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=cloudconvert-production%2F20240313%2Ffra%2Fs3%2Faws4_request&X-Amz-Date=20240313T125232Z&X-Amz-Expires=86400&X-Amz-Signature=47f29abd7d2833b597df60a061ece32135317b2715f4a5a5bd731d101328378a&X-Amz-SignedHeaders=host&response-content-disposition=attachment%3B%20filename%3D%22DALL%C2%B7E%202024-03-13%2013.49.29%20-%20A%20cute%2C%20cartoonish%20forklift%20in%20a%20simple%2C%20colorful%20style%2C%20isolated%20on%20a%20white%20background%2C%20suitable%20for%20a%2032x32%20pixels%20square%20format.png%22&response-content-type=image%2Fpng&x-id=GetObject
|
HostUrl=https://eu-central.storage.cloudconvert.com/tasks/72d14743-46c1-4131-ad52-b8c020251781/DALL%C2%B7E%202024-03-13%2013.49.29%20-%20A%20cute%2C%20cartoonish%20forklift%20in%20a%20simple%2C%20colorful%20style%2C%20isolated%20on%20a%20white%20background%2C%20suitable%20for%20a%2032x32%20pixels%20square%20format.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=cloudconvert-production%2F20240313%2Ffra%2Fs3%2Faws4_request&X-Amz-Date=20240313T125232Z&X-Amz-Expires=86400&X-Amz-Signature=47f29abd7d2833b597df60a061ece32135317b2715f4a5a5bd731d101328378a&X-Amz-SignedHeaders=host&response-content-disposition=attachment%3B%20filename%3D%22DALL%C2%B7E%202024-03-13%2013.49.29%20-%20A%20cute%2C%20cartoonish%20forklift%20in%20a%20simple%2C%20colorful%20style%2C%20isolated%20on%20a%20white%20background%2C%20suitable%20for%20a%2032x32%20pixels%20square%20format.png%22&response-content-type=image%2Fpng&x-id=GetObject
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
[ZoneTransfer]
|
[ZoneTransfer]
|
||||||
ZoneId=3
|
ZoneId=3
|
||||||
ReferrerUrl=https://cloudconvert.com/
|
ReferrerUrl=https://cloudconvert.com/
|
||||||
HostUrl=https://eu-central.storage.cloudconvert.com/tasks/bb36c777-c2d4-47c2-988b-532a79573e35/fruit.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=cloudconvert-production%2F20240313%2Ffra%2Fs3%2Faws4_request&X-Amz-Date=20240313T125445Z&X-Amz-Expires=86400&X-Amz-Signature=f19271408b0122b54201104cb6b223d8421964134753883343dec7c677f11f37&X-Amz-SignedHeaders=host&response-content-disposition=attachment%3B%20filename%3D%22fruit.png%22&response-content-type=image%2Fpng&x-id=GetObject
|
HostUrl=https://eu-central.storage.cloudconvert.com/tasks/bb36c777-c2d4-47c2-988b-532a79573e35/fruit.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=cloudconvert-production%2F20240313%2Ffra%2Fs3%2Faws4_request&X-Amz-Date=20240313T125445Z&X-Amz-Expires=86400&X-Amz-Signature=f19271408b0122b54201104cb6b223d8421964134753883343dec7c677f11f37&X-Amz-SignedHeaders=host&response-content-disposition=attachment%3B%20filename%3D%22fruit.png%22&response-content-type=image%2Fpng&x-id=GetObject
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
[ZoneTransfer]
|
[ZoneTransfer]
|
||||||
ZoneId=3
|
ZoneId=3
|
||||||
ReferrerUrl=https://cloudconvert.com/
|
ReferrerUrl=https://cloudconvert.com/
|
||||||
HostUrl=https://eu-central.storage.cloudconvert.com/tasks/7b680dc5-6ff4-4d66-a9fd-ee8b636e3bf1/nuclear_waste.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=cloudconvert-production%2F20240313%2Ffra%2Fs3%2Faws4_request&X-Amz-Date=20240313T125444Z&X-Amz-Expires=86400&X-Amz-Signature=09442679e02fcce160ea1f20fd133696d8b766e1e728a06c853e03fe9b951e05&X-Amz-SignedHeaders=host&response-content-disposition=attachment%3B%20filename%3D%22nuclear_waste.png%22&response-content-type=image%2Fpng&x-id=GetObject
|
HostUrl=https://eu-central.storage.cloudconvert.com/tasks/7b680dc5-6ff4-4d66-a9fd-ee8b636e3bf1/nuclear_waste.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=cloudconvert-production%2F20240313%2Ffra%2Fs3%2Faws4_request&X-Amz-Date=20240313T125444Z&X-Amz-Expires=86400&X-Amz-Signature=09442679e02fcce160ea1f20fd133696d8b766e1e728a06c853e03fe9b951e05&X-Amz-SignedHeaders=host&response-content-disposition=attachment%3B%20filename%3D%22nuclear_waste.png%22&response-content-type=image%2Fpng&x-id=GetObject
|
||||||
|
BIN
ai-wozek/siec/__pycache__/dataset.cpython-311.pyc
Normal file
BIN
ai-wozek/siec/__pycache__/dataset.cpython-39.pyc
Normal file
BIN
ai-wozek/siec/__pycache__/model.cpython-311.pyc
Normal file
40
ai-wozek/siec/dataset.py
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
import torch
|
||||||
|
import torch.nn as nn
|
||||||
|
import torch.optim as optim
|
||||||
|
from torch.utils.data import Dataset, DataLoader
|
||||||
|
import torchvision
|
||||||
|
import torchvision.transforms as transforms
|
||||||
|
from torchvision.datasets import ImageFolder
|
||||||
|
import timm
|
||||||
|
|
||||||
|
import matplotlib.pyplot as plt # For data viz
|
||||||
|
import pandas as pd
|
||||||
|
import numpy as np
|
||||||
|
import sys
|
||||||
|
|
||||||
|
class LabelDataset(Dataset):
|
||||||
|
def __init__(self, dataDirectory,transform=None):
|
||||||
|
self.data=ImageFolder(dataDirectory,transform=transform)
|
||||||
|
def __len__(self):
|
||||||
|
return len(self.data)
|
||||||
|
def __getitem__(self, idx):
|
||||||
|
return self.data[idx]
|
||||||
|
|
||||||
|
@property
|
||||||
|
def classes(self):
|
||||||
|
return self.data.classes
|
||||||
|
|
||||||
|
classname={v:k for k,v in ImageFolder('./train').class_to_idx.items()}
|
||||||
|
|
||||||
|
transform=transforms.Compose([
|
||||||
|
transforms.Resize((128,128)),
|
||||||
|
transforms.ToTensor(),
|
||||||
|
])
|
||||||
|
|
||||||
|
dataset=LabelDataset('./train',transform)
|
||||||
|
dataloader=DataLoader(dataset,batch_size=4, shuffle=True)
|
||||||
|
valset=LabelDataset('./val',transform)
|
||||||
|
valloader=DataLoader(valset,batch_size=4,shuffle=False)
|
||||||
|
|
||||||
|
for images,labels in dataloader:
|
||||||
|
break
|
BIN
ai-wozek/siec/model
Normal file
BIN
ai-wozek/siec/model.pt
Normal file
114
ai-wozek/siec/model.py
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
import torch
|
||||||
|
import torch.nn as nn
|
||||||
|
import torch.optim as optim
|
||||||
|
from torch.utils.data import Dataset, DataLoader
|
||||||
|
import torchvision
|
||||||
|
import torchvision.transforms as transforms
|
||||||
|
from torchvision.datasets import ImageFolder
|
||||||
|
import timm
|
||||||
|
from PIL import Image
|
||||||
|
|
||||||
|
import matplotlib.pyplot as plt # For data viz
|
||||||
|
import pandas as pd
|
||||||
|
import numpy as np
|
||||||
|
import sys
|
||||||
|
from siec import dataset
|
||||||
|
from glob import glob
|
||||||
|
|
||||||
|
class LabelClassifier(nn.Module):
|
||||||
|
def __init__(self,num_classes=3):
|
||||||
|
super(LabelClassifier, self).__init__()
|
||||||
|
self.model=timm.create_model('efficientnet_b0',pretrained=True)
|
||||||
|
self.features = nn.Sequential(*list(self.model.children())[:-1])
|
||||||
|
out_size=1280
|
||||||
|
self.classifier=nn.Linear(out_size,num_classes)
|
||||||
|
def forward(self,x):
|
||||||
|
x=self.features(x)
|
||||||
|
output=self.classifier(x)
|
||||||
|
return output
|
||||||
|
model=torch.load("./model")
|
||||||
|
|
||||||
|
criterion=nn.CrossEntropyLoss()
|
||||||
|
optimizer=optim.Adam(model.parameters(),lr=0.0005)
|
||||||
|
print(criterion(model(dataset.images),dataset.labels))
|
||||||
|
|
||||||
|
num_epochs=0
|
||||||
|
trainLosses=[]
|
||||||
|
valLosses=[]
|
||||||
|
|
||||||
|
device=torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
|
||||||
|
model.to(device)
|
||||||
|
|
||||||
|
for epoch in range(num_epochs):
|
||||||
|
model.train()
|
||||||
|
runningLoss=0.0
|
||||||
|
for images,labels in dataset.dataloader:
|
||||||
|
images, labels=images.to(device), labels.to(device)
|
||||||
|
optimizer.zero_grad()
|
||||||
|
outputs=model(images)
|
||||||
|
loss=criterion(outputs,labels)
|
||||||
|
loss.backward()
|
||||||
|
optimizer.step()
|
||||||
|
runningLoss+=loss.item()*images.size(0)
|
||||||
|
trainLoss=runningLoss/len(dataset.dataloader.dataset)
|
||||||
|
trainLosses.append(trainLoss)
|
||||||
|
|
||||||
|
model.eval()
|
||||||
|
runningLoss=0.0
|
||||||
|
with torch.no_grad():
|
||||||
|
for images, labels in dataset.valloader:
|
||||||
|
images, labels = images.to(device), labels.to(device)
|
||||||
|
outputs=model(images)
|
||||||
|
loss=criterion(outputs,labels)
|
||||||
|
runningLoss+=loss.item()*images.size(0)
|
||||||
|
valLoss=runningLoss/len(dataset.valloader.dataset)
|
||||||
|
valLosses.append(valLoss)
|
||||||
|
print(f"Epoch {epoch + 1}/{num_epochs} - Train loss: {trainLoss}, Validation loss: {valLoss}")
|
||||||
|
modell=torch.jit.script(model)
|
||||||
|
modell.save('model.pt')
|
||||||
|
|
||||||
|
|
||||||
|
def preprocess_image(image_path, transform):
|
||||||
|
image = Image.open(image_path).convert("RGB")
|
||||||
|
return image, transform(image).unsqueeze(0)
|
||||||
|
|
||||||
|
# Predict using the model
|
||||||
|
def predict(model, image_tensor, device):
|
||||||
|
model.eval()
|
||||||
|
with torch.no_grad():
|
||||||
|
image_tensor = image_tensor.to(device)
|
||||||
|
outputs = model(image_tensor)
|
||||||
|
probabilities = torch.nn.functional.softmax(outputs, dim=1)
|
||||||
|
print(outputs)
|
||||||
|
return probabilities.cpu().numpy().flatten()
|
||||||
|
|
||||||
|
# Visualization
|
||||||
|
def visualize_predictions(original_image, probabilities, class_names):
|
||||||
|
fig, axarr = plt.subplots(1, 2, figsize=(14, 7))
|
||||||
|
axarr[0].imshow(original_image)
|
||||||
|
axarr[0].axis("off")
|
||||||
|
|
||||||
|
# Display predictions
|
||||||
|
axarr[1].barh(class_names, probabilities)
|
||||||
|
axarr[1].set_xlabel("Probability")
|
||||||
|
axarr[1].set_title("Class Predictions")
|
||||||
|
axarr[1].set_xlim(0, 1)
|
||||||
|
|
||||||
|
plt.tight_layout()
|
||||||
|
plt.show()
|
||||||
|
transform = transforms.Compose([
|
||||||
|
transforms.Resize((128, 128)),
|
||||||
|
transforms.ToTensor()
|
||||||
|
])
|
||||||
|
test_images = glob('./train/*/*')
|
||||||
|
test_examples = np.random.choice(test_images, 10)
|
||||||
|
for example in test_examples:
|
||||||
|
model.eval()
|
||||||
|
original_image, image_tensor = preprocess_image(example, transform)
|
||||||
|
probabilities = predict(model, image_tensor, device)
|
||||||
|
print(probabilities)
|
||||||
|
|
||||||
|
# Assuming dataset.classes gives the class names
|
||||||
|
class_names = dataset.dataset.classes
|
||||||
|
visualize_predictions(original_image, probabilities, class_names)
|
||||||
|
model(image_tensor)
|
BIN
ai-wozek/siec/train/flammable/10189.jpg
Normal file
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 56 KiB |
After Width: | Height: | Size: 33 KiB |
After Width: | Height: | Size: 16 KiB |
BIN
ai-wozek/siec/train/flammable/B835481.jpg
Normal file
After Width: | Height: | Size: 92 KiB |
BIN
ai-wozek/siec/train/flammable/DG_23_large.jpeg
Normal file
After Width: | Height: | Size: 38 KiB |
After Width: | Height: | Size: 45 KiB |
After Width: | Height: | Size: 14 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 75 KiB |
After Width: | Height: | Size: 33 KiB |
BIN
ai-wozek/siec/train/flammable/flammable1_1.jpg
Normal file
After Width: | Height: | Size: 6.9 KiB |
After Width: | Height: | Size: 37 KiB |
BIN
ai-wozek/siec/train/flammable/il_570xN.3608249114_ng81.jpg
Normal file
After Width: | Height: | Size: 35 KiB |
BIN
ai-wozek/siec/train/flammable/il_570xN.3655835081_gebl.jpg
Normal file
After Width: | Height: | Size: 34 KiB |
BIN
ai-wozek/siec/train/flammable/il_570xN.3655859805_2wlx.jpg
Normal file
After Width: | Height: | Size: 32 KiB |
BIN
ai-wozek/siec/train/flammable/il_570xN.3655898297_9j9y.jpg
Normal file
After Width: | Height: | Size: 34 KiB |
BIN
ai-wozek/siec/train/flammable/image.gif
Normal file
After Width: | Height: | Size: 26 KiB |
BIN
ai-wozek/siec/train/flammable/images (10).jpg
Normal file
After Width: | Height: | Size: 7.1 KiB |
BIN
ai-wozek/siec/train/flammable/images (100).jpg
Normal file
After Width: | Height: | Size: 7.3 KiB |
BIN
ai-wozek/siec/train/flammable/images (100).png
Normal file
After Width: | Height: | Size: 4.9 KiB |
BIN
ai-wozek/siec/train/flammable/images (11).png
Normal file
After Width: | Height: | Size: 9.2 KiB |
BIN
ai-wozek/siec/train/flammable/images (12).jpg
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
ai-wozek/siec/train/flammable/images (14).jpg
Normal file
After Width: | Height: | Size: 6.4 KiB |
BIN
ai-wozek/siec/train/flammable/images (14).png
Normal file
After Width: | Height: | Size: 6.7 KiB |
BIN
ai-wozek/siec/train/flammable/images (15).jpg
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
ai-wozek/siec/train/flammable/images (15).png
Normal file
After Width: | Height: | Size: 4.8 KiB |
BIN
ai-wozek/siec/train/flammable/images (16).jpg
Normal file
After Width: | Height: | Size: 6.0 KiB |
BIN
ai-wozek/siec/train/flammable/images (20).png
Normal file
After Width: | Height: | Size: 4.7 KiB |
BIN
ai-wozek/siec/train/flammable/images (22).jpg
Normal file
After Width: | Height: | Size: 6.5 KiB |
BIN
ai-wozek/siec/train/flammable/images (27).jpg
Normal file
After Width: | Height: | Size: 9.2 KiB |
BIN
ai-wozek/siec/train/flammable/images (32).jpg
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
ai-wozek/siec/train/flammable/images (38).jpg
Normal file
After Width: | Height: | Size: 10 KiB |
BIN
ai-wozek/siec/train/flammable/images (39).png
Normal file
After Width: | Height: | Size: 7.4 KiB |
BIN
ai-wozek/siec/train/flammable/images (40).jpg
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
ai-wozek/siec/train/flammable/images (40).png
Normal file
After Width: | Height: | Size: 8.7 KiB |
BIN
ai-wozek/siec/train/flammable/images (42).png
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
ai-wozek/siec/train/flammable/images (43).png
Normal file
After Width: | Height: | Size: 4.1 KiB |
BIN
ai-wozek/siec/train/flammable/images (44).png
Normal file
After Width: | Height: | Size: 8.4 KiB |
BIN
ai-wozek/siec/train/flammable/images (45).png
Normal file
After Width: | Height: | Size: 4.7 KiB |
BIN
ai-wozek/siec/train/flammable/images (46).jpg
Normal file
After Width: | Height: | Size: 6.4 KiB |
BIN
ai-wozek/siec/train/flammable/images (47).png
Normal file
After Width: | Height: | Size: 7.2 KiB |
BIN
ai-wozek/siec/train/flammable/images (49).jpg
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
ai-wozek/siec/train/flammable/images (49).png
Normal file
After Width: | Height: | Size: 5.1 KiB |
BIN
ai-wozek/siec/train/flammable/images (5).png
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
ai-wozek/siec/train/flammable/images (50).jpg
Normal file
After Width: | Height: | Size: 6.0 KiB |
BIN
ai-wozek/siec/train/flammable/images (50).png
Normal file
After Width: | Height: | Size: 5.6 KiB |
BIN
ai-wozek/siec/train/flammable/images (52).png
Normal file
After Width: | Height: | Size: 4.7 KiB |
BIN
ai-wozek/siec/train/flammable/images (53).jpg
Normal file
After Width: | Height: | Size: 8.1 KiB |
BIN
ai-wozek/siec/train/flammable/images (53).png
Normal file
After Width: | Height: | Size: 9.3 KiB |
BIN
ai-wozek/siec/train/flammable/images (54).jpg
Normal file
After Width: | Height: | Size: 7.7 KiB |
BIN
ai-wozek/siec/train/flammable/images (55).png
Normal file
After Width: | Height: | Size: 3.9 KiB |
BIN
ai-wozek/siec/train/flammable/images (56).jpg
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
ai-wozek/siec/train/flammable/images (57).png
Normal file
After Width: | Height: | Size: 6.3 KiB |
BIN
ai-wozek/siec/train/flammable/images (58).png
Normal file
After Width: | Height: | Size: 5.9 KiB |
BIN
ai-wozek/siec/train/flammable/images (59).jpg
Normal file
After Width: | Height: | Size: 7.2 KiB |
BIN
ai-wozek/siec/train/flammable/images (60).jpg
Normal file
After Width: | Height: | Size: 10 KiB |
BIN
ai-wozek/siec/train/flammable/images (60).png
Normal file
After Width: | Height: | Size: 5.5 KiB |
BIN
ai-wozek/siec/train/flammable/images (61).png
Normal file
After Width: | Height: | Size: 5.6 KiB |
BIN
ai-wozek/siec/train/flammable/images (64).png
Normal file
After Width: | Height: | Size: 5.6 KiB |
BIN
ai-wozek/siec/train/flammable/images (65).jpg
Normal file
After Width: | Height: | Size: 4.7 KiB |
BIN
ai-wozek/siec/train/flammable/images (67).png
Normal file
After Width: | Height: | Size: 4.0 KiB |
BIN
ai-wozek/siec/train/flammable/images (68).png
Normal file
After Width: | Height: | Size: 7.7 KiB |
BIN
ai-wozek/siec/train/flammable/images (71).png
Normal file
After Width: | Height: | Size: 6.2 KiB |
BIN
ai-wozek/siec/train/flammable/images (72).jpg
Normal file
After Width: | Height: | Size: 8.0 KiB |
BIN
ai-wozek/siec/train/flammable/images (72).png
Normal file
After Width: | Height: | Size: 3.5 KiB |
BIN
ai-wozek/siec/train/flammable/images (73).jpg
Normal file
After Width: | Height: | Size: 8.5 KiB |
BIN
ai-wozek/siec/train/flammable/images (74).jpg
Normal file
After Width: | Height: | Size: 8.1 KiB |
BIN
ai-wozek/siec/train/flammable/images (74).png
Normal file
After Width: | Height: | Size: 5.3 KiB |
BIN
ai-wozek/siec/train/flammable/images (75).jpg
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
ai-wozek/siec/train/flammable/images (75).png
Normal file
After Width: | Height: | Size: 9.0 KiB |
BIN
ai-wozek/siec/train/flammable/images (76).png
Normal file
After Width: | Height: | Size: 6.7 KiB |
BIN
ai-wozek/siec/train/flammable/images (79).png
Normal file
After Width: | Height: | Size: 6.3 KiB |
BIN
ai-wozek/siec/train/flammable/images (8).png
Normal file
After Width: | Height: | Size: 6.0 KiB |
BIN
ai-wozek/siec/train/flammable/images (80).jpg
Normal file
After Width: | Height: | Size: 5.3 KiB |
BIN
ai-wozek/siec/train/flammable/images (80).png
Normal file
After Width: | Height: | Size: 4.7 KiB |
BIN
ai-wozek/siec/train/flammable/images (81).jpg
Normal file
After Width: | Height: | Size: 9.9 KiB |
BIN
ai-wozek/siec/train/flammable/images (81).png
Normal file
After Width: | Height: | Size: 5.7 KiB |