This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Import needed packages | |
import torch | |
import torch.nn as nn | |
from torchvision.datasets import CIFAR10 | |
from torchvision.transforms import transforms | |
from torch.utils.data import DataLoader | |
from torch.optim import Adam | |
from torch.autograd import Variable | |
import numpy as np |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Unit(nn.Module): | |
def __init__(self,in_channels,out_channels): | |
super(Unit,self).__init__() | |
self.conv = nn.Conv2d(in_channels=in_channels,kernel_size=3,out_channels=out_channels,stride=1,padding=1) | |
self.bn = nn.BatchNorm2d(num_features=out_channels) | |
self.relu = nn.ReLU() | |
def forward(self,input): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from deepstack import ServerConfig, Detection | |
config = ServerConfig("http://localhost:80") | |
detection = Detection(config,name="openlogo") | |
response = detection.detectObject(r"images/fedex.jpg",output="fedex_new.jpg") | |
for obj in response: | |
print("Name: {}, Confidence: {}".format(obj.label, obj.confidence)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//FUNCTION TO COMPUTE THE MAXIMUM PREDICTION AND ITS CONFIDENCE | |
public Object[] argmax(float[] array){ | |
int best = -1; | |
float best_confidence = 0.0f; | |
for(int i = 0;i < array.length;i++){ | |
float value = array[i]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Import needed packages | |
import torch | |
import torch.nn as nn | |
from torchvision.transforms import transforms | |
import matplotlib.pyplot as plt | |
import numpy as np | |
from torch.autograd import Variable | |
from torchvision.models import squeezenet1_1 | |
import torch.functional as F | |
import requests |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function printLoop(text): | |
while True: | |
println(text) | |
if __name__ == "__main__": | |
printLoop("Hello") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
app:layout_behavior="@string/appbar_scrolling_view_behavior" | |
tools:context=".Result" | |
tools:showIn="@layout/activity_result"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
tools:context=".Result"> | |
<android.support.design.widget.AppBarLayout | |
android:layout_width="match_parent" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.johnolafenwa.pytorchandroid; | |
import android.graphics.Bitmap; | |
import android.os.Bundle; | |
import android.support.v7.app.AppCompatActivity; | |
import android.support.v7.widget.Toolbar; | |
import android.widget.ImageView; | |
import android.widget.TextView; | |
public class Result extends AppCompatActivity { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.johnolafenwa.pytorchandroid; | |
import android.content.Intent; | |
import android.graphics.Bitmap; | |
import android.os.Bundle; | |
import android.provider.MediaStore; | |
import android.support.v7.app.AppCompatActivity; | |
import android.support.v7.widget.Toolbar; | |
import android.util.Log; | |
import android.view.View; |
NewerOlder