Skip to content

Instantly share code, notes, and snippets.

View scheckmedia's full-sized avatar

Tobias Scheck scheckmedia

View GitHub Profile
@scheckmedia
scheckmedia / MACS.py
Last active June 29, 2023 12:26
Using tf 2.0 api to calculate total flops and parameters
import tensorflow as tf
session = tf.compat.v1.Session()
graph = tf.compat.v1.get_default_graph()
with graph.as_default():
with session.as_default():
base_model = tf.keras.applications.MobileNetV2(weights='imagenet', input_tensor=tf.compat.v1.placeholder('float32', shape=(1,224,224,3)))
run_meta = tf.compat.v1.RunMetadata()
opts = tf.compat.v1.profiler.ProfileOptionBuilder.float_operation()
@scheckmedia
scheckmedia / flickr_image_download.py
Last active July 3, 2018 09:27
This simple Python 3 script allows you to download a bunch of images based on a given tag list.
import argparse
import flickrapi
import progressbar
import os
import concurrent.futures
from urllib.request import urlopen
progress = 0
api_key = u'SOME_KEY'
api_secret = u'SOME_SECRET'
@scheckmedia
scheckmedia / cpu_inference_mobilenet
Last active February 23, 2018 13:05
Inference time for ShuffleNet 1.5X compared to 0.75 MobileNet - CPU is an Intel Core i5 2.7 GHz and GPU is a GTX 1080
2018-02-23 11:47:17.086553: I tensorflow/tools/benchmark/benchmark_model.cc:443] Graph: [/Users/tobi/Desktop/frozen_mobilenet.pb]
2018-02-23 11:47:17.086832: I tensorflow/tools/benchmark/benchmark_model.cc:444] Input layers: [input_1]
2018-02-23 11:47:17.086842: I tensorflow/tools/benchmark/benchmark_model.cc:445] Input shapes: [1,224,224,3]
2018-02-23 11:47:17.086848: I tensorflow/tools/benchmark/benchmark_model.cc:446] Input types: [float]
2018-02-23 11:47:17.086854: I tensorflow/tools/benchmark/benchmark_model.cc:447] Output layers: [output_0]
2018-02-23 11:47:17.086862: I tensorflow/tools/benchmark/benchmark_model.cc:448] Num runs: [1000]
2018-02-23 11:47:17.086871: I tensorflow/tools/benchmark/benchmark_model.cc:449] Inter-inference delay (seconds): [-1.0]
2018-02-23 11:47:17.086877: I tensorflow/tools/benchmark/benchmark_model.cc:450] Inter-benchmark delay (seconds): [-1.0]
2018-02-23 11:47:17.086883: I tensorflow/tools/benchmark/benchmark_model.cc:452] Num threads: [-1]
2018-02-23 11:47:17.086888: I te
@scheckmedia
scheckmedia / dynupdate.py
Created May 13, 2017 16:51
simple dyndns updater in python for feste-ip.net
#!/usr/bin/env python
import urllib2, base64, syslog
username = "username"
password = "password"
host = "hostname.feste-ip.net"
url = "https://members.feste-ip.net/nic/update?hostname=%s" % (host)
auth = base64.b64encode('%s:%s' % (username, password))
@scheckmedia
scheckmedia / kernelStringifyer.py
Last active February 8, 2017 14:49
stringify shader or opencl kernels into a header file
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import StringIO
import os.path
import datetime
def remove_old_kernel(content, kernel_name):
kernel_start_pos = content.rfind("// kernel " + kernel_name + " start \n")