update
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
This commit is contained in:
parent
cbea8536d8
commit
12c34adbc3
|
|
@ -22,4 +22,5 @@ steps:
|
|||
- mkdir -p data
|
||||
- $mount_command
|
||||
- ls data/
|
||||
- CI=True python facenet_transfer_learning.py
|
||||
- source setenv.sh
|
||||
- CI=True python finetune/facenet_transfer_learning.py
|
||||
|
|
@ -13,6 +13,7 @@ from time import sleep
|
|||
from io import BytesIO
|
||||
from math import sqrt
|
||||
# from insightface.app import FaceAnalysis
|
||||
# pip install retinaface_pytorch
|
||||
from retinaface.pre_trained_models import get_model
|
||||
from retinaface.predict_single import Model
|
||||
from contextlib import redirect_stdout, redirect_stderr
|
||||
|
|
|
|||
|
|
@ -1,12 +1,9 @@
|
|||
from os import makedirs, environ
|
||||
|
||||
from torchinfo import summary
|
||||
from torchvision.models import Swin_V2_B_Weights, swin_v2_b
|
||||
from torch.nn import Linear, Dropout3d, Sequential, Dropout, Conv2d, CrossEntropyLoss, Identity, MaxPool2d, ReLU, \
|
||||
Softmax
|
||||
from torch.nn import Linear, Sequential, Dropout, CrossEntropyLoss, Identity, ReLU
|
||||
from torchvision.transforms import Compose, RandomResizedCrop, RandomRotation, ToTensor, \
|
||||
RandomHorizontalFlip, \
|
||||
Resize, CenterCrop, RandomAffine, GaussianBlur, RandomAutocontrast, InterpolationMode, AugMix, RandomErasing, \
|
||||
Resize, RandomAutocontrast, InterpolationMode, RandomErasing, \
|
||||
RandomEqualize, RandomPosterize, RandomPerspective, RandomGrayscale
|
||||
import matplotlib
|
||||
|
||||
|
|
@ -24,11 +21,9 @@ from torch.cuda import is_available
|
|||
from torch import no_grad, save, Tensor, load, device
|
||||
from datetime import datetime
|
||||
from distutils.util import strtobool
|
||||
from intel_extension_for_pytorch import optimize
|
||||
|
||||
CI = bool(strtobool(environ['CI']))
|
||||
# device = device('cuda' if is_available() else 'cpu')
|
||||
device = 'xpu'
|
||||
device = device('cuda' if is_available() else 'cpu')
|
||||
|
||||
model_path: str = join(datadir(), 'artifact', 'vggface2_facenet.pth')
|
||||
input_shape: int = 256
|
||||
|
|
@ -130,7 +125,7 @@ optimizer = Adam(params=[
|
|||
{'params': model_gpu[1].parameters(), 'lr': 1e-3},
|
||||
])
|
||||
|
||||
model, optimizer = optimize(model=model, optimizer=optimizer)
|
||||
# model, optimizer = optimize(model=model, optimizer=optimizer)
|
||||
scheduler = lr_scheduler.StepLR(optimizer=optimizer, step_size=10, gamma=0.9)
|
||||
epochs = 100
|
||||
|
||||
|
|
@ -7,7 +7,7 @@ from torchvision.transforms import Compose, RandomResizedCrop, RandomRotation, T
|
|||
RandomHorizontalFlip, \
|
||||
Resize, RandomAffine, RandomAdjustSharpness, RandomAutocontrast, RandomEqualize, GaussianBlur, Normalize
|
||||
from numpy import arange, ceil, full, float32, uint8, amax, amin
|
||||
from torchsummary import summary
|
||||
from torchinfo import summary
|
||||
from torch.nn import CrossEntropyLoss
|
||||
from torch.cuda.amp.grad_scaler import GradScaler
|
||||
from torch.cuda.amp import autocast
|
||||
|
|
@ -2,7 +2,6 @@ from torch import zeros, load, no_grad, stack, float32, nn
|
|||
from torch.utils.data import DataLoader
|
||||
from torchvision.datasets import ImageFolder
|
||||
from torchvision.transforms import Compose, functional, ToTensor, Resize, ConvertImageDtype
|
||||
from torch2trt import torch2trt
|
||||
from PIL import Image
|
||||
from numpy import array
|
||||
from os import listdir, makedirs
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
from cv2 import VideoCapture, getBuildInformation
|
||||
from torchvision.models.mobilenetv3 import MobileNetV3
|
||||
from settings import datadir
|
||||
|
||||
print(getBuildInformation())
|
||||
sample_video = VideoCapture('/home/tomokazu/PycharmProjects/helloproject-ai/koi_ing.webm')
|
||||
sample_video = VideoCapture('/movie_processing/koi_ing.webm')
|
||||
assert sample_video.isOpened()
|
||||
|
||||
ret = True
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
#!/usr/bin/env bash
|
||||
SOURCE="${BASH_SOURCE[0]}"
|
||||
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
|
||||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||
SOURCE="$(readlink "$SOURCE")"
|
||||
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
|
||||
done
|
||||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||
|
||||
PYTHONPATH=$PYTHONPATH:$DIR
|
||||
|
||||
export PYTHONPATH
|
||||
export DATA_DIR="${PYTHONPATH%/}/data"
|
||||
|
||||
type conda >/dev/null 2>&1 && conda activate helloproject-ai
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
from functools import cache
|
||||
from os import getcwd, pardir
|
||||
from os import getcwd, pardir, environ
|
||||
from os.path import join, abspath, dirname
|
||||
|
||||
blog_list = ['angerme-ss-shin', 'angerme-amerika', 'angerme-new', 'juicejuice-official', 'tsubaki-factory',
|
||||
|
|
@ -53,7 +53,7 @@ def theme_curator(theme: str, blog_id: str) -> str:
|
|||
|
||||
@cache
|
||||
def datadir():
|
||||
return join('/home/tomokazu/PycharmProjects/helloproject-ai/', 'data')
|
||||
return environ['DATA_DIR']
|
||||
|
||||
|
||||
request_header = {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import time
|
||||
from shutil import copyfile
|
||||
from insightface.app import FaceAnalysis
|
||||
from os import getcwd, listdir, makedirs
|
||||
|
|
@ -15,7 +16,15 @@ if not isdir(argv[2]):
|
|||
if not isfile(argv[1]):
|
||||
exit(1)
|
||||
|
||||
face_analysis = FaceAnalysis()
|
||||
face_analysis = FaceAnalysis(providers=[
|
||||
# 'CUDAExecutionProvider',
|
||||
# 'CPUExecutionProvider',
|
||||
('TensorrtExecutionProvider', {
|
||||
'trt_engine_cache_enable': True,
|
||||
'trt_engine_cache_path': join(getcwd(), 'onnx_cache'),
|
||||
'trt_fp16_enable': True,
|
||||
})
|
||||
], allowed_modules=['recognition', 'detection'])
|
||||
face_analysis.prepare(ctx_id=0, det_size=(160, 160))
|
||||
|
||||
print(argv)
|
||||
|
|
@ -35,6 +44,7 @@ makedirs(join(getcwd(), dir_name, "true"), exist_ok=True)
|
|||
makedirs(join(getcwd(), dir_name, "false"), exist_ok=True)
|
||||
|
||||
images = []
|
||||
begin = time.time()
|
||||
for file in image_files:
|
||||
if isfile(join(getcwd(), argv[2], file)):
|
||||
# print(join(getcwd(), argv[2], file))
|
||||
|
|
@ -50,3 +60,5 @@ for file in image_files:
|
|||
else:
|
||||
|
||||
copyfile(join(getcwd(), argv[2], file), join(getcwd(), dir_name, "false", file))
|
||||
|
||||
print(f"{time.time() - begin}sec")
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ from asyncio import to_thread, gather, run
|
|||
from aiofiles import open as a_open
|
||||
|
||||
valid_rate = 0.1
|
||||
SRC_DIR = join(r'/home/tomokazu/PycharmProjects/helloproject-ai/data/sample_set/')
|
||||
SRC_DIR = join(datadir(), 'sample_set')
|
||||
DEST_DIR = join(datadir(), 'dataset')
|
||||
|
||||
makedirs(DEST_DIR, exist_ok=True)
|
||||
|
|
@ -51,4 +51,3 @@ with tqdm(listdir(SRC_DIR)) as pbar:
|
|||
coroutines.append(co)
|
||||
# print(name, file)
|
||||
run(waiting(coroutines))
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
from os import getcwd
|
||||
from os.path import join
|
||||
from onnxruntime import InferenceSession, SessionOptions
|
||||
|
||||
onnx_session = InferenceSession(
|
||||
path_or_bytes="/home/tomokazu/.insightface/models/buffalo_l/w600k_r50.onnx",
|
||||
providers=[
|
||||
('TensorrtExecutionProvider', {
|
||||
'trt_engine_cache_enable': True,
|
||||
'trt_engine_cache_path': join(getcwd(), 'onnx_cache'),
|
||||
'trt_fp16_enable': True,
|
||||
})
|
||||
]
|
||||
)
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
from torch import load, randn, float, half, jit
|
||||
import torch_tensorrt
|
||||
from torch.nn import Module
|
||||
|
||||
model: Module = load(
|
||||
f='/home/tomokazu/PycharmProjects/helloproject-ai/data/artifact/facenet-tl_2023-05-28 23:05:09.874085/model.pth')
|
||||
model.cuda()
|
||||
model.eval()
|
||||
|
||||
example_input = randn(size=[1, 3, 224, 224]).float().cuda()
|
||||
|
||||
traced_script_module = jit.trace(model, example_inputs=[example_input])
|
||||
tensorrt_module = torch_tensorrt.compile(module=traced_script_module, inputs=[example_input],
|
||||
enabled_precisions={float, half},
|
||||
truncate_long_and_double=True)
|
||||
|
||||
jit.save(tensorrt_module, "trt_test.ts")
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
from torchvision.transforms import Compose
|
||||
import matplotlib.pyplot as plt
|
||||
from numpy import transpose
|
||||
import torchvision.datasets as datasets
|
||||
from torchvision import models
|
||||
from PIL import Image
|
||||
|
||||
print(dir(datasets))
|
||||
|
||||
|
||||
def show_image(x):
|
||||
fig = plt.figure(figsize=(10, 10))
|
||||
for s in range(len(x)):
|
||||
img = x[s].numpy()
|
||||
img = transpose(img, (1, 2, 0))
|
||||
ax1 = fig.add_subplot(1, len(x), s + 1)
|
||||
plt.axis('off')
|
||||
plt.imshow(img)
|
||||
|
||||
|
||||
model = models.inception_v3(models.Inception_V3_Weights)
|
||||
|
||||
print(model._get_name())
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
from super_gradients.training.models import get
|
||||
|
||||
yolo_nas = get(model_name='yolo_nas_l', pretrained_weights='coco').cuda()
|
||||
|
||||
yolo_nas.predict('橋迫鈴=angerme-new=12687767841-1.jpg', conf=0.8).show()
|
||||
Loading…
Reference in New Issue