<jupyter_start><jupyter_text>Malware Detection using DeepLearning and fast.ai frameworks<jupyter_code>%reload_ext autoreload
%autoreload 2
%matplotlib inline
from fastai.vision import *
from fastai.metrics import error_rate
bs = 64
!pip install PyDrive
import os
from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
from google.colab import auth
from oauth2client.client import GoogleCredentials

auth.authenticate_user()
gauth=GoogleAuth()
gauth.credentials = GoogleCredentials.get_application_default()
drive = GoogleDrive(gauth)
link = '<KEY>'
downloaded = drive.CreateFile({'id':link}) 
downloaded.GetContentFile('dataset.tar')
import tarfile
tar = tarfile.open("dataset.tar")
path = tar.extractall('DS/')
tar.close()
path = Path.cwd().joinpath("DS/dataset/")
path.ls()
#path = untar_data('https://drive.google.com/open?id=1SChipSdLmkoUkGMMZLLJv8Qwl3vi84eT')
path_benign = path/'benign'
path_malware = path/'malware'
#fnames = get_image_files(path_malware)
data = ImageDataBunch.from_folder(path, ds_tfms=get_transforms(), size=224)
data.show_batch(rows=3, figsize=(7,6))
print(data.c)
print(data.classes)
learn = create_cnn(data, models.resnet34, metrics = error_rate)
learn.model
learn.fit_one_cycle(4)
learn.fit_one_cycle(10)
interp = ClassificationInterpretation.from_learner(learn)
losses,idxs =  interp.top_losses()
interp.plot_top_losses(9,figsize=(9,6))
learn.unfreeze()
learn.fit_one_cycle(10)
learn.save('stage-1-malware-detection')
learn.lr_find()
learn.recorder.plot()
learn.unfreeze()
learn.fit_one_cycle(5, max_lr=slice(1e-6,1e-4))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1275, 'fraction_numerical': 0.019375, 'mean_word_length': 8.148571428571428, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '459830', 'license': 'MIT', 'n_tokens_mistral': 608, 'n_tokens_neox': 584, 'n_words': 100, 'path': 'Who-Done-It-Hacks/Malware Detection/Malware-Detection.ipynb', 'repo_name': 'Cluedo-MLH-Hackathon/Cluedo-Project', 'size': '1628'}