How to use the redisai.Backend.torch function in redisai

To help you get started, we’ve selected a few redisai examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github RedisAI / redisai-py / test / test_model.py View on Github external
def testPyTorchGraph(self):
        torch_graph = MyModule()
        path = f'{time.time()}.pt'
        save_model(torch_graph, path)
        model = load_model(path)
        os.remove(path)
        con = self.get_client()
        con.modelset('ptmodel', Backend.torch, Device.cpu, model)
        con.tensorset('a', Tensor.scalar(DType.float, 2, 5))
        con.tensorset('b', Tensor.scalar(DType.float, 3, 7))
        con.modelrun('ptmodel', ['a', 'b'], 'c')
        tensor = con.tensorget('c')
        self.assertEqual([5, 12], tensor.value)
github RedisAI / benchmarks / experiments / _pytorch / _redisai / client.py View on Github external
def init(config):
    model = raimodel.Model.load(config['modelpath'])
    host = config['server'].split(':')[0]
    port = config['server'].split(':')[1]
    init.con = rai.Client(host=host, port=port)
    init.con.modelset('model', rai.Backend.torch, rai.Device.cpu, model)
    image, init.img_class = get_one_image(transpose=(2, 0, 1))
    init.image = rai.BlobTensor.from_numpy(image)
github RedisAI / redisai-examples / python_client / torch_chatbot / redis_db.py View on Github external
def initiate(self):
        encoder_path = f'{dirname(dirname(dirname(__file__)))}/models/pytorch/chatbot/encoder.pt'
        decoder_path = f'{dirname(dirname(dirname(__file__)))}/models/pytorch/chatbot/decoder.pt'
        en_model = ml2rt.load_model(encoder_path)
        de_model = ml2rt.load_model(decoder_path)
        self.con.modelset('encoder', rai.Backend.torch, rai.Device.cpu, en_model)
        self.con.modelset('decoder', rai.Backend.torch, rai.Device.cpu, de_model)
github RedisAI / redisai-examples / sentinel / model_set.py View on Github external
import redisai as rai

con = rai.Client(host='159.65.150.75', port=6379, db=0)

pt_model_path = '../models/imagenet/pytorch/resnet50.pt'
script_path = '../models/imagenet/pytorch/data_processing_script.txt'

pt_model = rai.load_model(pt_model_path)
script = rai.load_script(script_path)

out1 = con.modelset('imagenet_model', rai.Backend.torch, rai.Device.cpu, pt_model)
out2 = con.scriptset('imagenet_script', rai.Device.cpu, script)
github RedisAI / redisai-examples / python_client / torch_chatbot / redis_db.py View on Github external
def initiate(self):
        encoder_path = f'{dirname(dirname(dirname(__file__)))}/models/pytorch/chatbot/encoder.pt'
        decoder_path = f'{dirname(dirname(dirname(__file__)))}/models/pytorch/chatbot/decoder.pt'
        en_model = ml2rt.load_model(encoder_path)
        de_model = ml2rt.load_model(decoder_path)
        self.con.modelset('encoder', rai.Backend.torch, rai.Device.cpu, en_model)
        self.con.modelset('decoder', rai.Backend.torch, rai.Device.cpu, de_model)