Skip to content

Instantly share code, notes, and snippets.

View AviKKi's full-sized avatar
🏠
Working from home

Atul Yadav AviKKi

🏠
Working from home
View GitHub Profile
@rj76
rj76 / pytest.py
Created December 24, 2018 08:55
django-tenant-schemas & django rest framework with pytest
# core mixins
from tenant_schemas.test.client import TenantClient
from rest_framework.test import APIClient
class My24ApiClient(TenantClient, APIClient):
pass
# core fixtures.py
from tenant_schemas.utils import get_public_schema_name, tenant_context
@himanshurawlani
himanshurawlani / export_saved_model.py
Created October 19, 2018 21:54
Script to convert Keras models to TensorFlow Serving SavedModel format
import tensorflow as tf
# The export path contains the name and the version of the model
tf.keras.backend.set_learning_phase(0) # Ignore dropout at inference
model = tf.keras.models.load_model('./inception.h5')
export_path = '../my_image_classifier/1'
# Fetch the Keras session and save the model
# The signature definition is defined by the input and output tensors
# And stored with the default serving key
@timonweb
timonweb / gist:2623793
Created May 6, 2012 18:55
Django: Programmatically saving image from URL to FileField or ImageField http://twigstechtips.blogspot.com/2012/04/django-programmatically-saving-image.html
class Product(models.Model):
# other fields
image = models.FileField(storage = MogileFSStorage(), upload_to = 'product_images')
from django.core.files import File
from django.core.files.temp import NamedTemporaryFile
product = Product()
# set all your variables here
product.save()