Giter Club home page Giter Club logo

craft_tflite's Introduction

Hi there ๐Ÿ‘‹

Myself Tulasi Ram. People call me as Tulasi.

  • ๐Ÿ”ญ Iโ€™m currently working at Amazon
  • ๐ŸŒฑ Iโ€™m currently learning tokenizers and Transfer Learning using pretrained Language Models.
  • ๐Ÿ‘ฏ Iโ€™m always open to collaborations.
  • ๐Ÿ’ฌ Ask me about Speech Recognition, On device Deep Learning.
  • ๐Ÿ“ซ Opensource contributions: tulasi.dev

Tulasi's github stats

craft_tflite's People

Contributors

milochen0418 avatar tulasiram58827 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

craft_tflite's Issues

Getting the actual text ?

So i input a picture in script tflite_inference.py
Then i go to subdirectory "result", i see a file like my picture but with the text highlighted in red.
No problem with what i see.
My problem is with the file "res_*.txt" that is with the picture: the file is empty. How to get the text ?
Is it a bug ?
What variable stores this data in the script?

Thank you very much for your answer

RuntimeError: tensorflow/lite/kernels/space_to_batch_nd.cc:83

RuntimeError                              Traceback (most recent call last)
[<ipython-input-43-65b5f67ee40d>](https://localhost:8080/#) in <module>()
     13 
     14 x = x.detach().numpy()
---> 15 y, feature = run_tflite_model(x)
     16 
     17 y = torch.from_numpy(y)

1 frames
[/usr/local/lib/python3.7/dist-packages/tensorflow/lite/python/interpreter.py](https://localhost:8080/#) in allocate_tensors(self)
    512   def allocate_tensors(self):
    513     self._ensure_safe()
--> 514     return self._interpreter.AllocateTensors()
    515 
    516   def _safe_to_run(self):

RuntimeError: tensorflow/lite/kernels/space_to_batch_nd.cc:83 final_dim_size % block_shape[dim] != 0 (4 != 0)Node number 66 (SPACE_TO_BATCH_ND) failed to prepare.Failed to apply the default TensorFlow Lite delegate indexed at 0.

How can i fix it?

Error converting model to tflite

Hi @tulasiram58827

Thank you for your great work. When I run your colab notebook CRAFT_TFLITE.ipynb. I get the following error -

ConverterError: /usr/local/lib/python3.6/dist-packages/tensorflow/python/saved_model/load.py:890:0: error: 'tf.MaxPool' op is neither a custom op nor a flex op

Do you know how to get around it ? Thanks

Setting Input Shape

Hi @tulasiram58827, I was wondering if it is possible to change the input format of the CRAFT, from [b c h w] to [b h w c], before converting it to tflite? By doing so, the input image need no reformatting (x.permute) when running the inference.

Any help would be very appreciated. Thanks!

run with craft.onnx

Hi,
thanks for this amazing work,
i'm running craft in 111 ms on windows, but i want to get maximum speed up , so i want to use onnx and i'm new to that,
but i'm confused that which scripts should i use to test?
( i want to use craft.onnx model so i dont need to produce it )

in below code line it is .pth version of craft.
parser.add_argument('--trained_model', default='../models/craft_mlt_25k.pth', type=str, help='pretrained model')

Other conversions not reflected in the notebook

I don't see the other conversion recipes you took in the conversion notebook. Could you include them?

You can also consider clearing the unnecessary outputs from the notebooks to keep them clean.

Run savedmodel_to_tflite.ipynb cause problems

I have run savedmodel_to_tflite.ipynb and got this error:
RuntimeError: Input to reshape is a tensor with 3840000 values, but the requested shape has 401408
(while executing 'Reshape' via Eager)Node number 450 (TfLiteFlexDelegate) failed to invoke.
Thank you so much

TFLITE Latency Problem

Although I converted craft model to tflite successfully and results seems pretty similar with the original model there are latency problems with converted tflite model.

Sample image used for testing.
Before Conversion:

  1. Model Size -- 80MB
  2. Time to Run -- 0.27s

After Converting to TFLITE

  1. Model Size -- 20MB
  2. Time to Run -- 25.1s

Hardware Used:

model name : Intel(R) Core(TM) i5-9300H CPU @ 2.40GHz

All the models used available in the repo.

@sayakpaul

craft_tflite on android

Hi @tulasiram58827 thank you for the awesome work on converting craft to tflite, I am trying to predict images from craft on android devices. I am having trouble converting input images and apply preprocessing before running inference on the model.

Bro can you please guide me on how shall i proceed with converting the following code :
`
image = loadImage(image_path)
image = cv2.resize(image, dsize=(800, 1280), interpolation=cv2.INTER_LINEAR)
img_resized, target_ratio, size_heatmap = resize_aspect_ratio(image, canvas_size, interpolation=cv2.INTER_LINEAR, mag_ratio=mag_ratio)
ratio_h = ratio_w = 1 / target_ratio

preprocessing

x = normalizeMeanVariance(img_resized)
x = torch.from_numpy(x).permute(2, 0, 1) # [h, w, c] to [c, h, w]
x = Variable(x.unsqueeze(0)) # [c, h, w] to [b, c, h, w]

forward pass

x = x.cpu().detach().numpy()
`

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.