Skip to content

Instantly share code, notes, and snippets.

View PhilipPurwoko's full-sized avatar
✈️
Work From Anywhere

Philip Purwoko PhilipPurwoko

✈️
Work From Anywhere
View GitHub Profile
@PhilipPurwoko
PhilipPurwoko / conditional.asm
Last active October 6, 2021 14:46
Assembly Language
section .data
pesanSiang: db 'Selamat Siang',10
pesanSiangLen: equ $-pesanSiang
pesanPagi: db 'Selamat Pagi',10
pesanPagiLen: equ $-pesanPagi
section .text
global _start
@PhilipPurwoko
PhilipPurwoko / create_mnist_model.py
Created February 5, 2021 02:10
Create MNIST model
from tensorflow import keras
from sklearn.metrics import classification_report
import numpy as np
# Load data provided by keras
data = keras.datasets.mnist
(x_train, y_train), (x_test, y_test) = data.load_data()
# Create model using sequential API
model = keras.Sequential([
package inheritance;
public class Dosen extends Pegawai {
long gatun = 1000000;
void hitungGatun(){
System.out.print("Gaji Tunjangan : ");
System.out.println(this.namaPegawai + " " + this.gatun);
}
void hitungGatot(){
import cv2
import datetime
import numpy as np
import matplotlib.pyplot as plt
import tensorflow as tf
keras = tf.keras
# Blit function to put text in video
def blit(text,frame,color,position=(100, 100)):
cv2.putText(frame, text, position, cv2.FONT_HERSHEY_SIMPLEX, 2, color, 4, cv2.LINE_4)
def predict(unseen_image = []):
test_data = batchData(unseen_image,for_test=True)
prediction = model.predict(test_data)
for image,pred in zip(unseen_image,prediction):
fig,axes = plt.subplots(nrows=1,ncols=2)
axes[0].imshow(processImage(image))
axes[0].axis(False)
axes[0].set_title('Actual Image')
# Create early stopping callback
early_stopping = keras.callbacks.EarlyStopping(monitor='val_loss',patience=3)
# Store model history into variable
history = model.fit(train_data,validation_data = valid_data,validation_freq=1,epochs = 50,callbacks = [early_stopping],verbose = 1,)
# Plot model training history
def plot_history():
plt.plot(history.history['acc'],label='acc')
plt.plot(history.history['val_acc'],label='val_acc')
# Create model structure
model = keras.Sequential([
# Input Layer
keras.layers.Conv2D(input_shape=(224,224,3),filters=32,kernel_size=(3,3),activation='relu'),
keras.layers.MaxPooling2D(),
# Hidden Layer
keras.layers.Conv2D(input_shape=(224,224,3),filters=64,kernel_size=(3,3),activation='relu'),
keras.layers.MaxPooling2D(),
keras.layers.Conv2D(input_shape=(224,224,3),filters=128,kernel_size=(3,3),activation='relu'),
# Processing image files into numpy array
def process_label(label):
label = [i == unique_label for i in label]
label = np.array(label).astype(int)
return label
def processImage(path):
image = tf.io.read_file(path)
image = tf.image.decode_jpeg(image,channels=3)
image = tf.image.convert_image_dtype(image,tf.float32)
import os
import random
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import tensorflow as tf
keras = tf.keras
import pickle
with open('AI_DrugClassifier.pkl','rb') as file:
model = pickle.load(file)
def self_prediction():
age = input('Age : ')
sex = input('Sex : ')
bp = input('BP : ')
chol = input('Cholesterol : ')