GithubHelp home page GithubHelp logo

Comments (4)

cedar33 avatar cedar33 commented on August 15, 2024 1

Thanks a lot, this is exactly what I need, I have learned so much from your code, thank you again

from tf_ner.

guillaumegenthial avatar guillaumegenthial commented on August 15, 2024

Hi @cedar33 ,
Yes, there is an efficient way to predict. Have a look at the serve.py script. It provides an example of how to use a predictor on a batch of size 1. You can create bigger batches as long as you pad the inputs. It will be efficient.

from tf_ner.

ahmadshabbir2468 avatar ahmadshabbir2468 commented on August 15, 2024
After batch size =50  we read 50 lines from file so server.py code will be like this  ????

def file_read_from_head(fname, nlines):
    from itertools import islice
    with open(fname) as f:
        for line in islice(f, nlines):
            print(line)
    return nlines


fifty_LINE= file_read_from_head('example1.txt', 50) #we read 50 line from file

if __name__ == '__main__':
    export_dir = 'saved_model'
    subdirs = [x for x in Path(export_dir).iterdir()
               if x.is_dir() and 'temp' not in str(x)]
    latest = str(sorted(subdirs)[-1])
    predict_fn = predictor.from_saved_model(latest)
    for LINE in fifty_LINE: 

	    words = [w.encode() for w in LINE.split()]
	    nwords = len(words)
	    predictions = predict_fn({'words': [words], 'nwords': [nwords]})
	    print(predictions)
#Loop over each line ??? or just 
#words = [w.encode() for w in fifty_LINE.split()] is enough

from tf_ner.

ahmadshabbir2468 avatar ahmadshabbir2468 commented on August 15, 2024

Thanks a lot, this is exactly what I need, I have learned so much from your code, thank you again

Much appreciated Brother
Kind regards Ahmad

from tf_ner.

Related Issues (20)

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.