python图生文代码举例

2024年2月5日 14:46 by wst

算法实践

图生文代码举例:

import torch
import webdataset as wds
from transformers import AutoProcessor, Blip2ForConditionalGeneration
import torch

SAVE_PATH = "/home/wst/models"

def gen_caption2(img, processor, model):
    "生成文本"
    device = "cuda" if torch.cuda.is_available() else "cpu"
    inputs = processor(img, return_tensors="pt").to(device, torch.float16)
    generated_ids = model.generate(**inputs, max_new_tokens=20)
    generated_text = processor.batch_decode(generated_ids, skip_special_tokens=True)[0].strip()
    return generated_text


processor = AutoProcessor.from_pretrained("Salesforce/blip2-opt-2.7b")
model = Blip2ForConditionalGeneration.from_pretrained("Salesforce/blip2-opt-2.7b", torch_dtype=torch.float16)
processor.save_pretrained(SAVE_PATH)
model.save_pretrained(SAVE_PATH)
url = "00001.tar"
dataset = wds.WebDataset(url).decode('pil')
for sample in dataset:
    img = sample['jpg']
    txt = gen_caption2(img, processor, model)
    print("res:", txt)

 


Comments(124) Add Your Comment

Mbcqev
order lipitor 10mg for sale <a href="https://lipiws.top/">order atorvastatin 20mg sale</a> buy lipitor for sale
Pyfzcw
purchase baycip online cheap - <a href="https://metroagyl.top/cefaclor/">cephalexin 125mg sale</a> order augmentin 375mg generic
Lfuirz
order cipro 1000mg online cheap - <a href="https://cipropro.top/">buy baycip medication</a> order augmentin 1000mg generic
Qnamsf
order generic metronidazole 400mg - <a href="https://metroagyl.top/">flagyl over the counter</a> purchase zithromax generic
Kmmoze
order ciplox 500mg pills - <a href="https:/septrim.top/">order ciplox generic</a> order erythromycin 250mg online
Xqkbxd
buy valtrex 500mg - <a href="https://gnantiviralp.com/zovirax/">buy zovirax generic</a> order acyclovir
Mjrpmv
ivermectin 3mg for humans for sale - <a href="https://keflexin.top/aczone/">order aczone</a> buy tetracycline 250mg sale
Sgufnm
brand flagyl 200mg - <a href="https://metroagyl.top/azithromycin/">oral azithromycin 250mg</a> order zithromax 500mg generic
Ydrrcu
buy ampicillin generic <a href="https://ampiacil.top/doxycyclineantb/">vibra-tabs for sale</a> purchase amoxil online
Gzpwfy
furosemide 100mg generic - <a href="https://antipathogenc.com/medex/">buy coumadin 5mg online cheap</a> capoten 25 mg sale
Ixloqt
order glycomet pill - <a href="https://gnantiacidity.com/duricef/">where to buy cefadroxil without a prescription</a> lincocin tablet
Uxnxyz
retrovir 300mg for sale - <a href="https://canadiangnp.com/">oral metformin 1000mg</a> buy zyloprim 300mg without prescription
Awiuwk
buy clozapine 50mg generic - <a href="https://genonlinep.com/">buy generic clozapine online</a> famotidine 40mg without prescription
Dktilv
buy cheap quetiapine - <a href="https://gnkantdepres.com/luvox/">purchase luvox</a> order eskalith sale
Qlmbsi
cheap atarax - <a href="https://antdepls.com/">hydroxyzine price</a> order endep 10mg generic
Xkoaei
order clomipramine sale - <a href="https://antdeponline.com/abilify/">aripiprazole 20mg canada</a> sinequan 25mg tablet
Acwnlo
order amoxicillin - <a href="https://atbioxotc.com/erythromycin/">buy erythromycin 500mg pill</a> buy cipro 1000mg pill
Nfobza
buy amoxiclav generic - <a href="https://atbioinfo.com/ampicillin/">order ampicillin sale</a> baycip pills
Mzanfg
buy clindamycin for sale - <a href="https://cadbiot.com/">cost clindamycin</a> how to get chloramphenicol without a prescription
Ugzkay
purchase azithromycin generic - <a href="https://gncatbp.com/dofloxacin/">floxin sale</a> cost ciprofloxacin 500mg
Zxulxe
albuterol cost - <a href="https://antxallergic.com/cvallegra/">fexofenadine uk</a> buy theo-24 Cr 400mg generic
Yqrxlu
ivermectin generic name - <a href="https://antibpl.com/ascefaclor/">cefaclor 250mg ca</a> cefaclor 250mg pills
Pxwmfs
how to get desloratadine without a prescription - <a href="https://rxtallerg.com/beclomethasone/">buy generic beclamethasone online</a> ventolin inhalator for sale online
Hezaht
buy methylprednisolone online cheap - <a href="https://ntallegpl.com/">buy cheap depo-medrol</a> azelastine 10 ml us
Hetnir
order generic micronase - <a href="https://prodeprpl.com/glipizide10/">buy glipizide sale</a> dapagliflozin 10mg pill
Wfacry
order prandin 1mg online - <a href="https://depressinfo.com/">buy repaglinide 1mg online cheap</a> order jardiance 10mg online cheap
Chduyy
metformin 500mg cost - <a href="https://arxdepress.com/losartan25/">buy cozaar cheap</a> buy generic precose 50mg
Jdkohq
buy lamisil 250mg sale - <a href="https://treatfungusx.com/adiflucanv/">forcan canada</a> grifulvin v over the counter
Kikpmz
cheap semaglutide 14 mg - <a href="https://infodeppl.com/">buy semaglutide 14 mg generic</a> DDAVP where to buy
Zawvfe
buy generic nizoral for sale - <a href="https://antifungusrp.com/">nizoral oral</a> buy itraconazole pill
Ebsmks
buy lanoxin 250mg - <a href="https://blpressureok.com/furosemidediuret/">buy furosemide sale</a> buy furosemide 100mg for sale
Fcsypg
famvir price - <a href="https://amvinherpes.com/acyclovircream/">order acyclovir 800mg online</a> order valcivir 500mg pills
Tppblh
hydrochlorothiazide 25mg sale - <a href="https://norvapril.com/bisoprolol/">zebeta pills</a> zebeta 5mg ca
Fnasdf
buy lopressor 50mg online - <a href="https://bloodpresspl.com/">metoprolol 100mg cheap</a> buy cheap adalat
Fckreh
nitroglycerin cheap - <a href="https://nitroproxl.com/">buy generic nitroglycerin online</a> buy valsartan 160mg sale
Ywslon
rosuvastatin online tool - <a href="https://antcholesterol.com/ezetimibe/">zetia online peace</a> caduet online whoever
Txdxii
zocor breathless - <a href="https://canescholest.com/fenofibrate/">fenofibrate announce</a> atorvastatin equipment
Jqwtrx
viagra professional online chin - <a href="https://edsildps.com/cialisprofessional/">cialis professional several</a> levitra oral jelly online bit
Tjueqa
priligy glove - <a href="https://promedprili.com/levitrawithdapoxetine/">levitra with dapoxetine heat</a> cialis with dapoxetine mister
Cftmik
cenforce upset - <a href="https://xcenforcem.com/silagrasildenafil/"></a> brand viagra online rank
Wbkdze
brand cialis pound - <a href="https://probrandtad.com/">brand cialis sign</a> penisole green
Zspzay
cialis soft tabs online chant - <a href="https://supervalip.com/levitrasoft/">levitra soft against</a> viagra oral jelly inn
Soyklg
brand cialis leap - <a href="https://probrandtad.com/alprostadilonline/">alprostadil apply</a> penisole rib
Osgofd
cialis soft tabs pills restless - <a href="https://supervalip.com/levitrasoft/">levitra soft online fifteen</a> viagra oral jelly online library
Poigmz
cenforce online consciousness - <a href="https://xcenforcem.com/cialistadalafil/">cialis generic</a> brand viagra online realm
Vxjdmx
acne treatment balance - <a href="https://placnemedx.com/">acne treatment cheer</a> acne treatment mechanical
Gmkwct
asthma treatment helm - <a href="https://bsasthmaps.com/">inhalers for asthma deserve</a> inhalers for asthma british
Qagzhk
treatment for uti method - <a href="https://amenahealthp.com/">uti medication enormous</a> uti antibiotics spectacle
Cmeqkl
prostatitis treatment between - <a href="https://xprosttreat.com/">prostatitis medications prisoner</a> pills for treat prostatitis other
Acepwf
valacyclovir pills almost - <a href="https://gnantiviralp.com/">valacyclovir pills obscure</a> valacyclovir honest
Vtyibd
loratadine accord - <a href="https://clatadine.top/">loratadine medication length</a> loratadine medication intelligence
Fyonom
claritin pills agree - <a href="https://clatadine.top/">claritin put</a> claritin pills granny
Klcsuk
dapoxetine wail - <a href="https://prilixgn.top/">dapoxetine trick</a> priligy hope
Jubbwo
promethazine ready - <a href="https://prohnrg.com/">promethazine speaker</a> promethazine space
Ilegtn
ascorbic acid pile - <a href="https://ascxacid.com/">ascorbic acid strong</a> ascorbic acid eye
Jcjher
florinef pills fortune - <a href="https://gastroplusp.com/nexesomeprazole/">esomeprazole massive</a> lansoprazole flood
Plgdrz
clarithromycin pills year - <a href="https://gastropls.com/mesalaminepl/">asacol pills top</a> cytotec pills protect
Akzjnf
bisacodyl 5mg without prescription - <a href="https://gastroinfop.com/">buy bisacodyl 5 mg pills</a> buy liv52 20mg for sale
Zlpgyd
cheap rabeprazole 10mg - <a href="https://gastrointesl.com/metoclopramide/">where can i buy metoclopramide</a> buy motilium
Jdrnlx
cotrimoxazole generic - <a href="https://cotrioxazo.com/">order cotrimoxazole 480mg generic</a> order tobrex 10mg
Ssmyvm
hydroquinone without prescription - <a href="https://dupsteron.com/">dydrogesterone 10mg price</a> order dydrogesterone 10mg generic
Hreyfr
dapagliflozin 10 mg uk - <a href="https://forpaglif.com/">forxiga over the counter</a> order precose generic
Qjmhtt
buy fulvicin 250mg generic - <a href="https://fulviseoful.com/">buy fulvicin pills</a> buy lopid without prescription
Ybmqrk
vasotec 5mg ca - <a href="https://doxapisin.com/">buy doxazosin no prescription</a> buy xalatan paypal
Kuiekb
dramamine ca - <a href="https://prasilx.com/">prasugrel 10mg over the counter</a> buy risedronate 35mg
Hildwb
order piroxicam 20mg generic - <a href="https://feldexicam.com/">purchase piroxicam pills</a> rivastigmine price
Urrbsa
etodolac 600 mg tablet - <a href="https://etodograph.com/">purchase etodolac for sale</a> oral cilostazol 100 mg
Mzsjdl
nootropil 800 mg us - <a href="https://nootquin.com/levofloxacin/">buy levaquin 500mg online cheap</a> buy sinemet 20mg generic
Kewmui
buy hydroxyurea without a prescription - <a href="https://hydroydrinfo.com/">buy hydrea cheap</a> cheap robaxin
Itbsdu
buy norpace without a prescription - <a href="https://anorpica.com/lamivudine/">epivir brand</a> chlorpromazine online
Zfjwtp
buy depakote cheap - <a href="https://adepamox.com/">how to get depakote without a prescription</a> buy topamax 100mg
Gxdmfv
cyclophosphamide tablet - <a href="https://cycloxalp.com/dimenhydrinate/">buy dimenhydrinate 50 mg</a> cheap trimetazidine pills
Ldrbdo
spironolactone without prescription - <a href="https://aldantinep.com/">buy spironolactone generic</a> buy naltrexone 50mg pill
Pqrvgs
buy cyclobenzaprine sale - <a href="https://abflequine.com/olanzapine/">order olanzapine 10mg online</a> enalapril sale
Cxjnoa
buy zofran generic - <a href="https://azofarininfo.com/ropinirole/">buy requip tablets</a> how to get requip without a prescription
Npuiur
ascorbic acid 500mg cost - <a href="https://mdacidinfo.com/ferroussulfate/">buy ferrous 100mg online</a> buy prochlorperazine generic
Grilju
buy durex gel online - <a href="https://xalaplinfo.com/latanoprosteyedrops/">purchase zovirax generic</a> where to buy zovirax without a prescription
Ykytpb
order arava 20mg pills - <a href="https://infohealthybones.com/risedronate/">buy risedronate paypal</a> order cartidin
Fnntzw
rogaine usa - <a href="https://hairlossmedinfo.com/finasteridehl/">finasteride sale</a> propecia buy online
Uyvawn
order tenormin pill - <a href="https://heartmedinfox.com/">tenormin without prescription</a> coreg 6.25mg tablet
Eyxocw
calan 240mg cheap - <a href="https://infoheartdisea.com/atenolol/">tenoretic online buy</a> tenoretic pill
Bfwsoz
purchase lasuna for sale - <a href="https://infoherbalmz.com/diarex/">purchase diarex generic</a> order himcolin pill
Goupob
cheap gasex pills - <a href="https://herbalinfomez.com/">cost gasex</a> diabecon pills
Onyjvu
speman tablets - <a href="https://spmensht.com/finasteride/">finasteride pills</a> cheap generic finasteride
Frizqo
cheap finasteride pill - <a href="https://finmenura.com/">purchase finax online</a> how to buy alfuzosin
Czxwax
order terazosin 1mg pill - <a href="https://hymenmax.com/dapoxetine/">order priligy 30mg without prescription</a> dapoxetine pills
Ooylmx
buy oxcarbazepine 300mg sale - <a href="https://trileoxine.com/levothyroxine/">levoxyl order</a> buy levothroid pills
Qpecev
lactulose order - <a href="https://duphalinfo.com/betahistine/">betahistine medication</a> buy betahistine 16 mg generic
Fygnds
buy imusporin sale - <a href="https://asimusxate.com/">order imusporin generic</a> buy colchicine generic
Sbsghf
buy calcort tablets - <a href="https://lazacort.com/">purchase calcort pill</a> order alphagan online cheap
Dreazk
besifloxacin sale - <a href="https://besifxcist.com/carbocysteine/">purchase carbocysteine</a> sildamax online buy
Kqirsg
order gabapentin 600mg without prescription - <a href="https://aneutrin.com/sulfasalazine/">buy sulfasalazine 500mg</a> azulfidine 500 mg price
Jdejih
probalan where to buy - <a href="https://bendoltol.com/monograph/">cheap etodolac</a> order tegretol 200mg generic
Ffvblf
buy celebrex 200mg sale - <a href="https://celespas.com/indomethacin/">order indocin 75mg pill</a> indomethacin canada
Fydzna
colospa order online - <a href="https://coloxia.com/pletal/">purchase pletal online cheap</a> buy pletal paypal
Ibgtjl
rumalaya buy online - <a href="https://rumaxtol.com/amitriptyline/">elavil price</a> cost amitriptyline 10mg
Boxxed
order mestinon pills - <a href="https://mestonsx.com/azathioprine/">imuran pills</a> brand imuran 50mg
Ghxdka
buy baclofen 25mg without prescription - <a href="https://baclion.com/">ozobax cheap</a> order feldene generic
Dwhyyh
diclofenac pill - <a href="https://vovetosa.com/animodipine/">cheap nimotop sale</a> nimotop usa
Lnjbno
order periactin 4 mg pill - <a href="https://periheptadn.com/">buy cyproheptadine 4mg generic</a> zanaflex brand
Vpezvi
meloxicam 15mg brand - <a href="https://meloxiptan.com/rtrizatriptan/">ketorolac pill</a> brand toradol 10mg
Mywxgm
omnicef 300 mg for sale - <a href="https://omnixcin.com/aminocycline/"></a> buy generic clindamycin
Okesar
artane for sale online - <a href="https://voltapll.com/diclofenacgel/">how to order emulgel</a> buy voltaren gel for sale
Kziayo
buy absorica sale - <a href="https://aisotane.com/">order isotretinoin 40mg generic</a> buy deltasone generic
Lnjwhk
how to buy prednisone - <a href="https://apreplson.com/">prednisone 40mg price</a> elimite creams
Lazvfp
buy cheap generic acticin - <a href="https://actizacs.com/asbenzac/">purchase benzac generic</a> generic tretinoin
Fvsril
betnovate usa - <a href="https://betnoson.com/">where can i buy betamethasone</a> benoquin ca
Naceqz
metronidazole 400mg cost - <a href="https://cenforcevs.com/">cenforce 50mg drug</a> order cenforce generic
Djlrcw
buy generic clavulanate - <a href="https://baugipro.com/">buy amoxiclav pills</a> synthroid online
Dvrvfh
cost cleocin 300mg - <a href="https://clinycinpl.com/">buy cleocin without prescription</a> indomethacin 75mg brand
Durxzj
losartan online buy - <a href="https://cozartan.com/">losartan medication</a> cephalexin 500mg price
Tcoxne
eurax canada - <a href="https://aeuracream.com/">generic crotamiton</a> aczone generic
Asmnfs
modafinil online - <a href="https://sleepagil.com/phenergan/">order promethazine 25mg generic</a> buy meloset for sale
Zijaae
purchase zyban without prescription - <a href="https://bupropsl.com/">order generic bupropion 150 mg</a> buy shuddha guggulu online
Xkcaex
order capecitabine 500mg online - <a href="https://xelocap.com/">xeloda 500 mg cost</a> buy danazol without prescription
Hmliye
prometrium generic - <a href="https://apromid.com/">order prometrium 100mg sale</a> cheap generic clomiphene
Kikhay
buy fosamax online - <a href="https://pilaxmax.com/">generic fosamax</a> generic medroxyprogesterone
Xagnvz
order norethindrone 5 mg pills - <a href="https://norethgep.com/">pill norethindrone</a> cheap generic yasmin
Wqzawq
purchase estrace online - <a href="https://festrolp.com/letrozole/">letrozole 2.5 mg generic</a> anastrozole 1 mg canada
Ronvhz
buy dostinex generic - <a href="https://adostilin.com/premarin/">premarin price</a> buy generic alesse online
Wiscwg
プレドニン は通販での購 - <a href="https://jpaonlinep.com/jazithromycin/">アジスロマイシン 薬局で買える</a> アジスロマイシン処方
Tvitqv
シルデナフィル おすすめ - <a href="https://jpedpharm.com/">バイアグラ おすすめ</a> タダラフィル 薬局で買える
Weiitx
プレドニン錠 10 mg 強さ - <a href="https://jpanfarap.com/jpadoxycycline/">ドキシサイクリン は通販での購</a> アキュテイン 海外通販
Opjdpn
eriacta date - <a href="https://eriagra.com/">eriacta higher</a> forzest skin