Giter VIP home page Giter VIP logo

simple-v2-wrapper's Introduction

Fast API Wrapper for V2 Inference Protocol


This is a one stop solution for creating v2 requests, in the most basic format ever! Simply send in the deployed model urls and your inputs and watch the magic happen. Returns Json formatted output data with interpretable code which makes it even easier to use with almost every huggingface model.


The Pipeline


Currently supports the following pipelines:


https://huggingface.co/sshleifer/tiny-gpt2

text-generation

https://huggingface.co/d4data/biomedical-ner-all/tree/main

token-classification

https://huggingface.co/typeform/distilbert-base-uncased-mnli

zero-shot-classification

https://huggingface.co/TahaDouaji/detr-doc-table-detection

object-detection

Input Format:

{
  "hf_pipeline": string,
  "model_deployed_url": string,
  "inputs": any,
  "parameters":any
}


The following script is an example in action!

cUrls can also be used similarly


Object detection:
import requests

headers = {
    'accept': 'application/json',
    'Content-Type': 'application/json',
}

data = '{ "hf_pipeline": "object-detection","model_deployed_url": "https://object-intern-yajat.demo1.truefoundry.com/v2/models/object/infer", "inputs": "https://www.w3.org/WAI/WCAG22/Techniques/pdf/img/table-word.jpg","parameters": {}}'

response = requests.post('https://v2.demo1.truefoundry.com/predict', headers=headers, data=data)

print(response.json())

Output:
[
	{
		"score":0.9906801581382751,
		"label":"table",
		"box":{
			"xmin":20,
			"ymin":54,
			"xmax":479,
			"ymax":257
		}
	}
]



Text Generation:
import requests

headers = {
    'accept': 'application/json',
    'Content-Type': 'application/json',
}

data = '{"hf_pipeline": "text-generation","model_deployed_url":"https://text-generation-ml-intern-assign.tfy-gcp-standard-usce1.devtest.truefoundry.tech/v2/models/text-generation/infer","inputs": "Hello, how are you today? ","parameters": {"min_new_tokens": 10,"do_sample": true,"temperature": 1.0,"max_new_tokens": 20,"num_return_sequences": 5}}'

response = requests.post('https://v2.demo1.truefoundry.com/predict', headers=headers, data=data)

print(response.json())

Output:

[
	{
		"generated_text":"Hello how are you today?PocketProsPros Late Boone� brutality skilletOutside omega Late workshops omega representations predators incarcer WheelsGy PocketGy Pocket653MostOutside representations factors Bend grandchildren praying boils Medicacious Redux mutual omega skillet Pocket predators predators� representations Tre"
	}
]


Working on localhost

To get started on your own pc,

  1. Clone the repo:
git clone https://github.com/yxjat/simple-v2-wrapper
  1. Run the uvicorn server
uvicorn main:app --host 0.0.0.0 --port 8000

And you're all set!



Deployed models:

https://object-intern-yajat.demo1.truefoundry.com
https://textgen-intern-yajat.demo1.truefoundry.com

Note! the object detection pipeline might take a while to respond (10s)

simple-v2-wrapper's People

Contributors

yxjat avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.