Fermé

Add multithreading to script python

I have the next script... and i want multithreading for that the script go most fast.

import torch

#import argparse

import flask

import json

from multiprocess import Pool

from sentence_splitter import SentenceSplitter, split_text_into_sentences

from transformers import PegasusForConditionalGeneration, PegasusTokenizer

from flask import request, jsonify

model_name = 'tuner007/pegasus_paraphrase'

torch_device = 'cuda' if torch.cuda.is_available() else 'cpu'

tokenizer = PegasusTokenizer.from_pretrained(model_name)

model = PegasusForConditionalGeneration.from_pretrained(model_name).to(torch_device)

app = [login to view URL](__name__)

[login to view URL]["DEBUG"] = True

def get_response(input_text):

batch = tokenizer([input_text],truncation=True,padding='longest',num_proc=7, max_length=60, return_tensors="pt").to(torch_device)

translated = [login to view URL](**batch,max_length=60,num_beams=10, num_return_sequences=1, temperature=1.5)

tgt_text = tokenizer.batch_decode(translated, skip_special_tokens=True)

return tgt_text

@[login to view URL]('/api/rewrite', methods=['POST'])

def home():

#data = request.get_json(force=True, silent=True)

#args = parser.parse_args()

#context = [login to view URL]

splitter = SentenceSplitter(language='en')

sentence_list = [login to view URL]([login to view URL]['text'])

paraphrase = []

for i in sentence_list:

result = get_response(i)

[login to view URL](result)

paraphrase2 = [' '.join(x) for x in paraphrase]

paraphrase3 = [' '.join(x for x in paraphrase2) ]

paraphrased_text = str(paraphrase3).strip('[]').strip("'")

return { "result": paraphrased_text }

[login to view URL](host='0.0.0.0', port=5027)

Compétences : Python, Architecture Logicielle, Linux, Programmation C, Programmation C++

En voir plus : want add wallpaper script website, want buy myspace add train script, i want a programmer python from india, i want producer of my script, i am a nursery teacher i want to write report on how the student behave and weather is rainy, i want to see the writer name and and the olddiest novel is na tum bewafa ho hum bewafa hain, i want to translate my name into arabic writing, i want a ball python, i want to develop python gui, i want to see a bigger than 9m australian python having a launch, i want to translate a sentence into english, i want to write a marketing plan fast, www i want licence that will allow me to use python as my pet com, www oasis com i want sell python skin, i want aproject of python using pandas, I want Game Character Animation Controller Script, I want a logo for my company. The name of the company is morningstar education . The main business is to provide online academic, i will give the script python, i want to become python expert, i want to sell my property fast

Concernant l'employeur :
( 2 commentaires ) Breña, Lima, Peru

Nº du projet : #31587147

5 freelances font une offre moyenne de 29 $ pour ce travail

mubashirallii

Hello, I have read your description and I can make the program multi threaded to improve performance and save you some time. Let discuss in details and I'll make it multi threaded. Thanks, Looking forward to your resp Plus

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% USD en 1 jour
(13 Commentaires)
4.8
ShoaibMustafa88

Hi, i understand that you want some extra speed in your project. i have experience with multithreading and i can do it for you in two days. i will have to study the script first in order to integrate it with multithrea Plus

%bids___i_sum_sub_35% %project_currencyDetails_sign_sub_36% USD en 2 jours
(2 Commentaires)
2.6
valbandurka

Howdy, I can add multithreading to your script so it'll make it blazing fast and I've got some ideas to optimize the code also. I'm professional Python developer with 8+ years of experience and I've got must have knowl Plus

%bids___i_sum_sub_35% %project_currencyDetails_sign_sub_36% USD en 2 jours
(2 Commentaires)
0.7
otanadze

Hello! I have experience in improvement python algorithm speed by adding multithreading/multiprocessing and ready to help you by adding multithreading insted your loops and changing lists to more efficient python data Plus

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% USD en 1 jour
(0 Commentaires)
0.0
notzpes

I have over 4 years of experience with python. I have done allot of stuff with multithreading in the past. This should be no problem for me. Message me for more details.

%bids___i_sum_sub_35% %project_currencyDetails_sign_sub_36% USD en 3 jours
(0 Commentaires)
0.0