Đã Đóng

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='', port=5027)

Kĩ năng: Python, Kiến trúc phần mềm, Linux, Lập trình C, Lập trình C++

Xem nhiều hơn: 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

Về Bên Thuê:
( 2 nhận xét ) Breña, Lima, Peru

ID dự án: #31587147

5 freelancer chào giá trung bình$29 cho công việc này


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 Thêm

$50 USD trong 1 ngày
(13 Nhận xét)

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 Thêm

$14 USD trong 2 ngày
(2 Nhận xét)

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 Thêm

$30 USD trong 2 ngày
(2 Nhận xét)

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 Thêm

$30 USD trong 1 ngày
(0 Nhận xét)

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.

$20 USD trong 3 ngày
(0 Nhận xét)