利用CSDN將圖片自動(dòng)存入AI Studio :pic2bml

      網(wǎng)友投稿 693 2025-03-31

      簡(jiǎn) 介:

      編寫了python程序 pic2bml 可以快速借助于CSDN的圖片存儲(chǔ)功能,將圖片串入AI Studio。對(duì)于有少量臨時(shí)圖片傳輸編程,可以增加程序開發(fā)的效率。

      關(guān)鍵詞:

      pic2bml,bml,csdn

      背景介紹

      文章目錄

      基本方案

      使用命令

      實(shí)現(xiàn)代碼

      總 結(jié)

      背景介紹

      文章目錄

      基本方案

      使用命令

      實(shí)現(xiàn)代碼

      總 結(jié)

      AI Studio是百度提供的進(jìn)行人工智能開發(fā)的平臺(tái)。在提供了百度人工智能網(wǎng)絡(luò)框架之外,利用AI Studio 可以將軟件、數(shù)據(jù)庫、模型訓(xùn)練和部署整合在一起。免去了個(gè)人在自己的計(jì)算機(jī)平臺(tái)是好搭建平臺(tái)和維護(hù)開發(fā)過程瑣事。

      在AI Studio界面中,提供了多種途徑允許將自己的圖片數(shù)據(jù)文件導(dǎo)入云端的計(jì)算機(jī)中:

      直接利用文件上載的功能;這種上載的數(shù)據(jù)文件只能在一個(gè)工程項(xiàng)目中應(yīng)用;

      利用自行建立數(shù)據(jù)庫的功能;這種方式可以允許在不同的工程之間共享數(shù)據(jù)庫;

      既然有了這些手段,為什么還需要編程將圖片自動(dòng)導(dǎo)入AI Studio呢?

      主要還是為了能夠產(chǎn)生自動(dòng)化調(diào)試和測(cè)試使用。對(duì)于少量實(shí)時(shí)采集的圖片,如果希望能夠測(cè)試相關(guān)的算法,通過編程自動(dòng)導(dǎo)入可以提高程序開發(fā)的效率。

      1.1 基本方案

      基本處理過程

      將圖片上載CSDN獲得鏈接

      在AI Studio BML中wget圖片

      存儲(chǔ)在本地,或者直接應(yīng)用

      1.2 使用命令

      # Transfer picture into BaiDu Machine Learning Lab. # Usage: pic2bml * [work/1.jpg] # transfer clipboard pic to BML # picid [] # transfer DOP id to BML # 0 [] # transfer DOP picture dop to BML # picfile [] # Transfer picfile to BML # # default directory: temp # source: * : Clipboard # 0 : DOP picture # digit: DOP id # picfile # dest: default: work/1.jpg # picfile: default directory : Work # =var : Set url variable

      1

      2

      3

      4

      5

      6

      7

      8

      9

      10

      11

      12

      13

      1.3 實(shí)現(xiàn)代碼

      #!/usr/local/bin/python # -*- coding: gbk -*- #============================================================ # PIC2BML.PY -- by Dr. ZhuoQing 2021-12-22 # # Transfer picture into BaiDu Machine Learning Lab. # Usage: pic2bml * [work/1.jpg] # transfer clipboard pic to BML # picid [] # transfer DOP id to BML # 0 [] # transfer DOP picture dop to BML # picfile [] # Transfer picfile to BML # # default directory: temp # source: * : Clipboard # 0 : DOP picture # digit: DOP id # picfile # dest: default: work/1.jpg # picfile: default directory : Work # =var : Set url variable # # Note: #============================================================ from headm import * from PIL import Image from io import BytesIO import win32clipboard import pyautogui #------------------------------------------------------------ csdn_window = '寫文章-CSDN博客' AIStudio_Title = 'BML CodeLab' #------------------------------------------------------------ def send_to_clipboard(clip_type, data): win32clipboard.OpenClipboard() win32clipboard.EmptyClipboard() win32clipboard.SetClipboardData(clip_type, data) win32clipboard.CloseClipboard() #------------------------------------------------------------ def ClipboardCopyImage(imageFile): if not os.path.isfile(imageFile): return image = Image.open(imageFile) output = BytesIO() image.convert('RGB').save(output, 'BMP') data = output.getvalue()[14:] output.close() send_to_clipboard(win32clipboard.CF_DIB, data) #------------------------------------------------------------ def GetCSDNImageURL(): tspsendwindowkey(csdn_window, ' ',noreturn=1) tspsendwindowkey(csdn_window, 'z', control=1,noreturn=1) tspsendwindowkey(csdn_window, 'v', control=1,noreturn=1) for i in range(40): time.sleep(.5) readdata = tspread() if readdata[2] == 1: break if readdata[7] != 0: break if readdata[8] != 0: exit() if readdata[9] != 0: exit() tspsendwindowkey(csdn_window, 'c', control=1, noreturn=1) if clipboard.paste().find('在這里插入圖片描述') >= 0: tspbeep(1500, 200) time.sleep(.25) break printf('\a') tspsendwindowkey(csdn_window, 'ac', control=1, noreturn=1) time.sleep(.1) pastestr = clipboard.paste().split('![在這里插入圖片描述](') if len(pastestr) < 2: printf("Can not find the ![Insert picture] discriptor !\a") return '' tspsendwindowkey(csdn_window, 'z', control=1) pastestr = pastestr[1].split(')')[0] replacestr = '![在這里插入圖片描述](%s)'%pastestr pastestr = pastestr.split('?')[0] return pastestr #------------------------------------------------------------ def GetCSDNImageUrl(imageFile): ClipboardCopyImage(imageFile) return GetCSDNImageURL() #------------------------------------------------------------ filename = '*' outfile = '/home/aistudio/work/1.jpg' #------------------------------------------------------------ if len(sys.argv) > 1: filename = sys.argv[1] if filename.isdigit(): picfile = tspgetdopfile(int(filename)) extstr = picfile.split('.')[-1].upper() if not extstr in 'JPG BMP'.split(): printf("%s is not picture!\a"%picfile) exit() filename = picfile if len(sys.argv) > 2: outfile = sys.argv[2] if outfile.find('.') < 0: if filename.find('.') > 0: fn = filename.split('.')[-1] outfile = outfile + '.' + fn else: outfile = outfile + '.jpg' if outfile.find('/home/aistudio/work') < 0: outfile = '/home/aistudio/work/' + outfile #------------------------------------------------------------ printf('%s --> %s\a'%(filename, outfile)) #------------------------------------------------------------ if filename.find('http') >= 0: urlstr = filename else: urlstr = GetCSDNImageUrl(filename) #------------------------------------------------------------ aiscmd = "!wget -q --output-document=%s %s"%(outfile, urlstr) clipboard.copy(aiscmd) rect = tspgetwindowrect(AIStudio_Title) pyautogui.click((rect[2] - 150), rect[1] + 320) tspsendwindowkey(AIStudio_Title, "a", control=1, noreturn=1) tspsendwindowkey(AIStudio_Title, "av", control=1, noreturn=1) tspsendwindowkey(AIStudio_Title, "\r", shift=1, noreturn=1) tspfocuswindow('TEASOFT:1') #------------------------------------------------------------ # END OF FILE : PIC2BML.PY #============================================================

      1

      2

      3

      4

      5

      6

      7

      8

      9

      10

      11

      12

      13

      14

      15

      16

      17

      18

      19

      20

      21

      22

      23

      24

      25

      26

      27

      28

      29

      30

      31

      32

      33

      34

      35

      36

      37

      38

      39

      40

      41

      42

      43

      44

      45

      46

      47

      48

      49

      50

      51

      52

      53

      54

      55

      56

      57

      58

      59

      60

      61

      62

      63

      64

      65

      66

      67

      68

      69

      70

      71

      72

      73

      74

      75

      76

      77

      78

      79

      80

      81

      82

      83

      84

      85

      86

      87

      88

      89

      90

      91

      92

      93

      94

      95

      96

      97

      98

      99

      100

      101

      102

      103

      104

      105

      106

      107

      108

      109

      110

      111

      112

      113

      114

      115

      116

      117

      118

      119

      120

      121

      122

      123

      124

      125

      126

      127

      利用CSDN將圖片自動(dòng)存入AI Studio :pic2bml

      128

      129

      130

      131

      132

      133

      134

      135

      136

      137

      138

      139

      140

      141

      142

      143

      144

      145

      146

      147

      148

      149

      150

      151

      152

      寫了python程序 pic2bml 可以快速借助于CSDN的圖片存儲(chǔ)功能,將圖片串入AI Studio。對(duì)于有少量臨時(shí)圖片傳輸編程,可以增加程序開發(fā)的效率。

      AI

      版權(quán)聲明:本文內(nèi)容由網(wǎng)絡(luò)用戶投稿,版權(quán)歸原作者所有,本站不擁有其著作權(quán),亦不承擔(dān)相應(yīng)法律責(zé)任。如果您發(fā)現(xiàn)本站中有涉嫌抄襲或描述失實(shí)的內(nèi)容,請(qǐng)聯(lián)系我們jiasou666@gmail.com 處理,核實(shí)后本網(wǎng)站將在24小時(shí)內(nèi)刪除侵權(quán)內(nèi)容。

      版權(quán)聲明:本文內(nèi)容由網(wǎng)絡(luò)用戶投稿,版權(quán)歸原作者所有,本站不擁有其著作權(quán),亦不承擔(dān)相應(yīng)法律責(zé)任。如果您發(fā)現(xiàn)本站中有涉嫌抄襲或描述失實(shí)的內(nèi)容,請(qǐng)聯(lián)系我們jiasou666@gmail.com 處理,核實(shí)后本網(wǎng)站將在24小時(shí)內(nèi)刪除侵權(quán)內(nèi)容。

      上一篇:ERP系統(tǒng)提供競(jìng)爭(zhēng)優(yōu)勢(shì)的4種方式
      下一篇:怎樣合并兩個(gè)單元格(如何合并兩個(gè)單元格)
      相關(guān)文章
      亚洲精品无码久久不卡| 久久亚洲AV成人无码国产电影 | 亚洲va久久久噜噜噜久久男同| 国产亚洲漂亮白嫩美女在线| 亚洲av永久无码一区二区三区| 亚洲人成黄网在线观看| 亚洲国产精品综合久久网各 | 亚洲第一黄色网址| 亚洲福利精品一区二区三区| 国产亚洲精品国产福利在线观看 | 风间由美在线亚洲一区| 日韩欧美亚洲中文乱码| 在线观看亚洲免费| 亚洲成人影院在线观看| 久久久久亚洲精品无码网址| 亚洲精品tv久久久久久久久 | 亚洲av无码专区青青草原| 亚洲国产成人久久精品大牛影视 | 夜夜亚洲天天久久| 亚洲春色另类小说| 亚洲人成www在线播放| 亚洲人成网站色7799| 激情无码亚洲一区二区三区| 亚洲成a人片在线观看日本麻豆| 一本色道久久综合亚洲精品高清| 亚洲香蕉网久久综合影视| 亚洲av丰满熟妇在线播放| 亚洲黄色一级毛片| tom影院亚洲国产一区二区| 亚洲人成无码网站在线观看| 国产精品亚洲专区无码WEB| 亚洲精品第一国产综合精品99| 中文字幕亚洲天堂| 久久久久亚洲av无码尤物| 久久亚洲AV成人无码国产| 亚洲国产成AV人天堂无码| 亚洲精品无码久久久久秋霞| 亚洲 另类 无码 在线| 久久久久亚洲精品无码网址| 亚洲男人的天堂在线播放| 亚洲国产一区在线观看|