欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

基于python神經(jīng)卷積網(wǎng)絡(luò)的人臉識(shí)別

 更新時(shí)間:2018年05月24日 14:55:36   作者:Lxingmo  
這篇文章主要為大家詳細(xì)介紹了基于python神經(jīng)卷積網(wǎng)絡(luò)的人臉識(shí)別,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了基于神經(jīng)卷積網(wǎng)絡(luò)的人臉識(shí)別,供大家參考,具體內(nèi)容如下

1.人臉識(shí)別整體設(shè)計(jì)方案


客_服交互流程圖:


2.服務(wù)端代碼展示

sk = socket.socket() 
# s.bind(address) 將套接字綁定到地址。在AF_INET下,以元組(host,port)的形式表示地址。 
sk.bind(("172.29.25.11",8007)) 
# 開(kāi)始監(jiān)聽(tīng)傳入連接。 
sk.listen(True) 
 
while True: 
 for i in range(100): 
  # 接受連接并返回(conn,address),conn是新的套接字對(duì)象,可以用來(lái)接收和發(fā)送數(shù)據(jù)。address是連接客戶(hù)端的地址。 
  conn,address = sk.accept() 
 
  # 建立圖片存儲(chǔ)路徑 
  path = str(i+1) + '.jpg' 
 
  # 接收?qǐng)D片大?。ㄗ止?jié)數(shù)) 
  size = conn.recv(1024) 
  size_str = str(size,encoding="utf-8") 
  size_str = size_str[2 :] 
  file_size = int(size_str) 
 
  # 響應(yīng)接收完成 
  conn.sendall(bytes('finish', encoding="utf-8")) 
 
  # 已經(jīng)接收數(shù)據(jù)大小 has_size 
  has_size = 0 
  # 創(chuàng)建圖片并寫(xiě)入數(shù)據(jù) 
  f = open(path,"wb") 
  while True: 
   # 獲取 
   if file_size == has_size: 
    break 
   date = conn.recv(1024) 
   f.write(date) 
   has_size += len(date) 
  f.close() 
 
  # 圖片縮放 
  resize(path) 
  # cut_img(path):圖片裁剪成功返回True;失敗返回False 
  if cut_img(path): 
   yuchuli() 
   result = test('test.jpg') 
   conn.sendall(bytes(result,encoding="utf-8")) 
  else: 
   print('falue') 
   conn.sendall(bytes('人眼檢測(cè)失敗,請(qǐng)保持圖片眼睛清晰',encoding="utf-8")) 
  conn.close() 

3.圖片預(yù)處理

1)圖片縮放

# 根據(jù)圖片大小等比例縮放圖片 
def resize(path): 
 image=cv2.imread(path,0) 
 row,col = image.shape 
 if row >= 2500: 
  x,y = int(row/5),int(col/5) 
 elif row >= 2000: 
  x,y = int(row/4),int(col/4) 
 elif row >= 1500: 
  x,y = int(row/3),int(col/3) 
 elif row >= 1000: 
  x,y = int(row/2),int(col/2) 
 else: 
  x,y = row,col 
 # 縮放函數(shù) 
 res=cv2.resize(image,(y,x),interpolation=cv2.INTER_CUBIC) 
 cv2.imwrite(path,res) 

2)直方圖均衡化和中值濾波

# 直方圖均衡化 
eq = cv2.equalizeHist(img) 
# 中值濾波 
lbimg=cv2.medianBlur(eq,3) 

3)人眼檢測(cè)

# -*- coding: utf-8 -*- 
# 檢測(cè)人眼,返回眼睛數(shù)據(jù) 
 
import numpy as np 
import cv2 
 
def eye_test(path): 
 # 待檢測(cè)的人臉路徑 
 imagepath = path 
 
 # 獲取訓(xùn)練好的人臉參數(shù) 
 eyeglasses_cascade = cv2.CascadeClassifier('haarcascade_eye_tree_eyeglasses.xml') 
 
 # 讀取圖片 
 img = cv2.imread(imagepath) 
 # 轉(zhuǎn)為灰度圖像 
 gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) 
 
 # 檢測(cè)并獲取人眼數(shù)據(jù) 
 eyeglasses = eyeglasses_cascade.detectMultiScale(gray) 
 # 人眼數(shù)為2時(shí)返回左右眼位置數(shù)據(jù) 
 if len(eyeglasses) == 2: 
  num = 0 
  for (e_gx,e_gy,e_gw,e_gh) in eyeglasses: 
   cv2.rectangle(img,(e_gx,e_gy),(e_gx+int(e_gw/2),e_gy+int(e_gh/2)),(0,0,255),2) 
   if num == 0: 
    x1,y1 = e_gx+int(e_gw/2),e_gy+int(e_gh/2) 
   else: 
    x2,y2 = e_gx+int(e_gw/2),e_gy+int(e_gh/2) 
   num += 1 
  print('eye_test') 
  return x1,y1,x2,y2 
 else: 
  return False 

4)人眼對(duì)齊并裁剪

# -*- coding: utf-8 -*- 
# 人眼對(duì)齊并裁剪 
 
# 參數(shù)含義: 
# CropFace(image, eye_left, eye_right, offset_pct, dest_sz) 
# eye_left is the position of the left eye 
# eye_right is the position of the right eye 
# 比例的含義為:要保留的圖像靠近眼鏡的百分比, 
# offset_pct is the percent of the image you want to keep next to the eyes (horizontal, vertical direction) 
# 最后保留的圖像的大小。 
# dest_sz is the size of the output image 
# 
import sys,math 
from PIL import Image 
from eye_test import eye_test 
 
 # 計(jì)算兩個(gè)坐標(biāo)的距離 
def Distance(p1,p2): 
 dx = p2[0]- p1[0] 
 dy = p2[1]- p1[1] 
 return math.sqrt(dx*dx+dy*dy) 
 
 # 根據(jù)參數(shù),求仿射變換矩陣和變換后的圖像。 
def ScaleRotateTranslate(image, angle, center =None, new_center =None, scale =None, resample=Image.BICUBIC): 
 if (scale is None)and (center is None): 
  return image.rotate(angle=angle, resample=resample) 
 nx,ny = x,y = center 
 sx=sy=1.0 
 if new_center: 
  (nx,ny) = new_center 
 if scale: 
  (sx,sy) = (scale, scale) 
 cosine = math.cos(angle) 
 sine = math.sin(angle) 
 a = cosine/sx 
 b = sine/sx 
 c = x-nx*a-ny*b 
 d =-sine/sy 
 e = cosine/sy 
 f = y-nx*d-ny*e 
 return image.transform(image.size, Image.AFFINE, (a,b,c,d,e,f), resample=resample) 
 
 # 根據(jù)所給的人臉圖像,眼睛坐標(biāo)位置,偏移比例,輸出的大小,來(lái)進(jìn)行裁剪。 
def CropFace(image, eye_left=(0,0), eye_right=(0,0), offset_pct=(0.2,0.2), dest_sz = (70,70)): 
 # calculate offsets in original image 計(jì)算在原始圖像上的偏移。 
 offset_h = math.floor(float(offset_pct[0])*dest_sz[0]) 
 offset_v = math.floor(float(offset_pct[1])*dest_sz[1]) 
 # get the direction 計(jì)算眼睛的方向。 
 eye_direction = (eye_right[0]- eye_left[0], eye_right[1]- eye_left[1]) 
 # calc rotation angle in radians 計(jì)算旋轉(zhuǎn)的方向弧度。 
 rotation =-math.atan2(float(eye_direction[1]),float(eye_direction[0])) 
 # distance between them # 計(jì)算兩眼之間的距離。 
 dist = Distance(eye_left, eye_right) 
 # calculate the reference eye-width 計(jì)算最后輸出的圖像兩只眼睛之間的距離。 
 reference = dest_sz[0]-2.0*offset_h 
 # scale factor # 計(jì)算尺度因子。 
 scale =float(dist)/float(reference) 
 # rotate original around the left eye # 原圖像繞著左眼的坐標(biāo)旋轉(zhuǎn)。 
 image = ScaleRotateTranslate(image, center=eye_left, angle=rotation) 
 # crop the rotated image # 剪切 
 crop_xy = (eye_left[0]- scale*offset_h, eye_left[1]- scale*offset_v) # 起點(diǎn) 
 crop_size = (dest_sz[0]*scale, dest_sz[1]*scale) # 大小 
 image = image.crop((int(crop_xy[0]),int(crop_xy[1]),int(crop_xy[0]+crop_size[0]),int(crop_xy[1]+crop_size[1]))) 
 # resize it 重置大小 
 image = image.resize(dest_sz, Image.ANTIALIAS) 
 return image 
 
def cut_img(path): 
 image = Image.open(path) 
 
 # 人眼識(shí)別成功返回True;否則,返回False 
 if eye_test(path): 
  print('cut_img') 
  # 獲取人眼數(shù)據(jù) 
  leftx,lefty,rightx,righty = eye_test(path) 
 
  # 確定左眼和右眼位置 
  if leftx > rightx: 
   temp_x,temp_y = leftx,lefty 
   leftx,lefty = rightx,righty 
   rightx,righty = temp_x,temp_y 
 
  # 進(jìn)行人眼對(duì)齊并保存截圖 
  CropFace(image, eye_left=(leftx,lefty), eye_right=(rightx,righty), offset_pct=(0.30,0.30), dest_sz=(92,112)).save('test.jpg') 
  return True 
 else: 
  print('falue') 
  return False 

4.用神經(jīng)卷積網(wǎng)絡(luò)訓(xùn)練數(shù)據(jù)

# -*- coding: utf-8 -*- 
 
from numpy import * 
import cv2 
import tensorflow as tf 
 
# 圖片大小 
TYPE = 112*92 
# 訓(xùn)練人數(shù) 
PEOPLENUM = 42 
# 每人訓(xùn)練圖片數(shù) 
TRAINNUM = 15 #( train_face_num ) 
# 單人訓(xùn)練人數(shù)加測(cè)試人數(shù) 
EACH = 21 #( test_face_num + train_face_num ) 
 
# 2維=>1維 
def img2vector1(filename): 
 img = cv2.imread(filename,0) 
 row,col = img.shape 
 vector1 = zeros((1,row*col)) 
 vector1 = reshape(img,(1,row*col)) 
 return vector1 
 
# 獲取人臉數(shù)據(jù) 
def ReadData(k): 
 path = 'face_flip/' 
 train_face = zeros((PEOPLENUM*k,TYPE),float32) 
 train_face_num = zeros((PEOPLENUM*k,PEOPLENUM)) 
 test_face = zeros((PEOPLENUM*(EACH-k),TYPE),float32) 
 test_face_num = zeros((PEOPLENUM*(EACH-k),PEOPLENUM)) 
 
 # 建立42個(gè)人的訓(xùn)練人臉集和測(cè)試人臉集 
 for i in range(PEOPLENUM): 
  # 單前獲取人 
  people_num = i + 1 
  for j in range(k): 
   #獲取圖片路徑 
   filename = path + 's' + str(people_num) + '/' + str(j+1) + '.jpg' 
   #2維=>1維 
   img = img2vector1(filename) 
 
   #train_face:每一行為一幅圖的數(shù)據(jù);train_face_num:儲(chǔ)存每幅圖片屬于哪個(gè)人 
   train_face[i*k+j,:] = img/255 
   train_face_num[i*k+j,people_num-1] = 1 
 
  for j in range(k,EACH): 
   #獲取圖片路徑 
   filename = path + 's' + str(people_num) + '/' + str(j+1) + '.jpg' 
 
   #2維=>1維 
   img = img2vector1(filename) 
 
   # test_face:每一行為一幅圖的數(shù)據(jù);test_face_num:儲(chǔ)存每幅圖片屬于哪個(gè)人 
   test_face[i*(EACH-k)+(j-k),:] = img/255 
   test_face_num[i*(EACH-k)+(j-k),people_num-1] = 1 
 
 return train_face,train_face_num,test_face,test_face_num 
 
# 獲取訓(xùn)練和測(cè)試人臉集與對(duì)應(yīng)lable 
train_face,train_face_num,test_face,test_face_num = ReadData(TRAINNUM) 
 
# 計(jì)算測(cè)試集成功率 
def compute_accuracy(v_xs, v_ys): 
 global prediction 
 y_pre = sess.run(prediction, feed_dict={xs: v_xs, keep_prob: 1}) 
 correct_prediction = tf.equal(tf.argmax(y_pre,1), tf.argmax(v_ys,1)) 
 accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32)) 
 result = sess.run(accuracy, feed_dict={xs: v_xs, ys: v_ys, keep_prob: 1}) 
 return result 
 
# 神經(jīng)元權(quán)重 
def weight_variable(shape): 
 initial = tf.truncated_normal(shape, stddev=0.1) 
 return tf.Variable(initial) 
 
# 神經(jīng)元偏置 
def bias_variable(shape): 
 initial = tf.constant(0.1, shape=shape) 
 return tf.Variable(initial) 
 
# 卷積 
def conv2d(x, W): 
 # stride [1, x_movement, y_movement, 1] 
 # Must have strides[0] = strides[3] = 1 
 return tf.nn.conv2d(x, W, strides=[1, 1, 1, 1], padding='SAME') 
 
# 最大池化,x,y步進(jìn)值均為2 
def max_pool_2x2(x): 
 # stride [1, x_movement, y_movement, 1] 
 return tf.nn.max_pool(x, ksize=[1,2,2,1], strides=[1,2,2,1], padding='SAME') 
 
 
# define placeholder for inputs to network 
xs = tf.placeholder(tf.float32, [None, 10304])/255. # 112*92 
ys = tf.placeholder(tf.float32, [None, PEOPLENUM]) # 42個(gè)輸出 
keep_prob = tf.placeholder(tf.float32) 
x_image = tf.reshape(xs, [-1, 112, 92, 1]) 
# print(x_image.shape) # [n_samples, 112,92,1] 
 
# 第一層卷積層 
W_conv1 = weight_variable([5,5, 1,32]) # patch 5x5, in size 1, out size 32 
b_conv1 = bias_variable([32]) 
h_conv1 = tf.nn.relu(conv2d(x_image, W_conv1) + b_conv1) # output size 112x92x32 
h_pool1 = max_pool_2x2(h_conv1)       # output size 56x46x64 
 
 
# 第二層卷積層 
W_conv2 = weight_variable([5,5, 32, 64]) # patch 5x5, in size 32, out size 64 
b_conv2 = bias_variable([64]) 
h_conv2 = tf.nn.relu(conv2d(h_pool1, W_conv2) + b_conv2) # output size 56x46x64 
h_pool2 = max_pool_2x2(h_conv2)       # output size 28x23x64 
 
 
# 第一層神經(jīng)網(wǎng)絡(luò)全連接層 
W_fc1 = weight_variable([28*23*64, 1024]) 
b_fc1 = bias_variable([1024]) 
# [n_samples, 28, 23, 64] ->> [n_samples, 28*23*64] 
h_pool2_flat = tf.reshape(h_pool2, [-1, 28*23*64]) 
h_fc1 = tf.nn.relu(tf.matmul(h_pool2_flat, W_fc1) + b_fc1) 
h_fc1_drop = tf.nn.dropout(h_fc1, keep_prob) 
 
# 第二層神經(jīng)網(wǎng)絡(luò)全連接層 
W_fc2 = weight_variable([1024, PEOPLENUM]) 
b_fc2 = bias_variable([PEOPLENUM]) 
prediction = tf.nn.softmax((tf.matmul(h_fc1_drop, W_fc2) + b_fc2)) 
 
 
# 交叉熵?fù)p失函數(shù) 
cost = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(logits = tf.matmul(h_fc1_drop, W_fc2)+b_fc2, labels=ys)) 
regularizers = tf.nn.l2_loss(W_fc1) + tf.nn.l2_loss(b_fc1) +tf.nn.l2_loss(W_fc2) + tf.nn.l2_loss(b_fc2) 
# 將正則項(xiàng)加入損失函數(shù) 
cost += 5e-4 * regularizers 
# 優(yōu)化器優(yōu)化誤差值 
train_step = tf.train.AdamOptimizer(1e-4).minimize(cost) 
 
sess = tf.Session() 
init = tf.global_variables_initializer() 
saver = tf.train.Saver() 
sess.run(init) 
 
# 訓(xùn)練1000次,每50次輸出測(cè)試集測(cè)試結(jié)果 
for i in range(1000): 
 sess.run(train_step, feed_dict={xs: train_face, ys: train_face_num, keep_prob: 0.5}) 
 if i % 50 == 0: 
  print(sess.run(prediction[0],feed_dict= {xs: test_face,ys: test_face_num,keep_prob: 1})) 
  print(compute_accuracy(test_face,test_face_num)) 
# 保存訓(xùn)練數(shù)據(jù) 
save_path = saver.save(sess,'my_data/save_net.ckpt') 

5.用神經(jīng)卷積網(wǎng)絡(luò)測(cè)試數(shù)據(jù)

# -*- coding: utf-8 -*- 
# 兩層神經(jīng)卷積網(wǎng)絡(luò)加兩層全連接神經(jīng)網(wǎng)絡(luò) 
 
from numpy import * 
import cv2 
import tensorflow as tf 
 
# 神經(jīng)網(wǎng)絡(luò)最終輸出個(gè)數(shù) 
PEOPLENUM = 42 
 
# 2維=>1維 
def img2vector1(img): 
 row,col = img.shape 
 vector1 = zeros((1,row*col),float32) 
 vector1 = reshape(img,(1,row*col)) 
 return vector1 
 
# 神經(jīng)元權(quán)重 
def weight_variable(shape): 
 initial = tf.truncated_normal(shape, stddev=0.1) 
 return tf.Variable(initial) 
 
# 神經(jīng)元偏置 
def bias_variable(shape): 
 initial = tf.constant(0.1, shape=shape) 
 return tf.Variable(initial) 
 
# 卷積 
def conv2d(x, W): 
 # stride [1, x_movement, y_movement, 1] 
 # Must have strides[0] = strides[3] = 1 
 return tf.nn.conv2d(x, W, strides=[1, 1, 1, 1], padding='SAME') 
 
# 最大池化,x,y步進(jìn)值均為2 
def max_pool_2x2(x): 
 # stride [1, x_movement, y_movement, 1] 
 return tf.nn.max_pool(x, ksize=[1,2,2,1], strides=[1,2,2,1], padding='SAME') 
 
# define placeholder for inputs to network 
xs = tf.placeholder(tf.float32, [None, 10304])/255. # 112*92 
ys = tf.placeholder(tf.float32, [None, PEOPLENUM]) # 42個(gè)輸出 
keep_prob = tf.placeholder(tf.float32) 
x_image = tf.reshape(xs, [-1, 112, 92, 1]) 
# print(x_image.shape) # [n_samples, 112,92,1] 
 
# 第一層卷積層 
W_conv1 = weight_variable([5,5, 1,32]) # patch 5x5, in size 1, out size 32 
b_conv1 = bias_variable([32]) 
h_conv1 = tf.nn.relu(conv2d(x_image, W_conv1) + b_conv1) # output size 112x92x32 
h_pool1 = max_pool_2x2(h_conv1)       # output size 56x46x64 
 
 
# 第二層卷積層 
W_conv2 = weight_variable([5,5, 32, 64]) # patch 5x5, in size 32, out size 64 
b_conv2 = bias_variable([64]) 
h_conv2 = tf.nn.relu(conv2d(h_pool1, W_conv2) + b_conv2) # output size 56x46x64 
h_pool2 = max_pool_2x2(h_conv2)       # output size 28x23x64 
 
 
# 第一層神經(jīng)網(wǎng)絡(luò)全連接層 
W_fc1 = weight_variable([28*23*64, 1024]) 
b_fc1 = bias_variable([1024]) 
# [n_samples, 28, 23, 64] ->> [n_samples, 28*23*64] 
h_pool2_flat = tf.reshape(h_pool2, [-1, 28*23*64]) 
h_fc1 = tf.nn.relu(tf.matmul(h_pool2_flat, W_fc1) + b_fc1) 
h_fc1_drop = tf.nn.dropout(h_fc1, keep_prob) 
 
# 第二層神經(jīng)網(wǎng)絡(luò)全連接層 
W_fc2 = weight_variable([1024, PEOPLENUM]) 
b_fc2 = bias_variable([PEOPLENUM]) 
prediction = tf.nn.softmax((tf.matmul(h_fc1_drop, W_fc2) + b_fc2)) 
 
sess = tf.Session() 
init = tf.global_variables_initializer() 
 
# 下載訓(xùn)練數(shù)據(jù) 
saver = tf.train.Saver() 
saver.restore(sess,'my_data/save_net.ckpt') 
 
# 返回簽到人名 
def find_people(people_num): 
 if people_num == 41: 
  return '任童霖' 
 elif people_num == 42: 
  return 'LZT' 
 else: 
  return 'another people' 
 
def test(path): 
 # 獲取處理后人臉 
 img = cv2.imread(path,0)/255 
 test_face = img2vector1(img) 
 print('true_test') 
 
 # 計(jì)算輸出比重最大的人及其所占比重 
 prediction1 = sess.run(prediction,feed_dict={xs:test_face,keep_prob:1}) 
 prediction1 = prediction1[0].tolist() 
 people_num = prediction1.index(max(prediction1))+1 
 result = max(prediction1)/sum(prediction1) 
 print(result,find_people(people_num)) 
 
 # 神經(jīng)網(wǎng)絡(luò)輸出最大比重大于0.5則匹配成功 
 if result > 0.50: 
  # 保存簽到數(shù)據(jù) 
  qiandaobiao = load('save.npy') 
  qiandaobiao[people_num-1] = 1 
  save('save.npy',qiandaobiao) 
 
  # 返回 人名+簽到成功 
  print(find_people(people_num) + '已簽到') 
  result = find_people(people_num) + ' 簽到成功' 
 else: 
  result = '簽到失敗' 
 return result 

神經(jīng)卷積網(wǎng)絡(luò)入門(mén)簡(jiǎn)介

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • Python 字典詳解

    Python 字典詳解

    這篇文章主要介紹了Python的字典,結(jié)合實(shí)例形式詳細(xì)分析了Python字典的概念、創(chuàng)建、格式化及常用操作方法與相關(guān)注意事項(xiàng),需要的朋友可以參考下
    2021-10-10
  • Python GUI編程之tkinter 關(guān)于 ttkbootstrap 的使用詳解

    Python GUI編程之tkinter 關(guān)于 ttkbootstrap 的使用

    ttkbootstrap 是一個(gè)基于 tkinter 的界面美化庫(kù),使用這個(gè)工具可以開(kāi)發(fā)出類(lèi)似前端 bootstrap 風(fēng)格的 tkinter 桌面程序,這篇文章主要介紹了Python GUI編程之tkinter 關(guān)于 ttkbootstrap 的使用詳解,需要的朋友可以參考下
    2022-03-03
  • Keras模型轉(zhuǎn)成tensorflow的.pb操作

    Keras模型轉(zhuǎn)成tensorflow的.pb操作

    這篇文章主要介紹了Keras模型轉(zhuǎn)成tensorflow的.pb操作,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2020-07-07
  • 深入探討Python復(fù)合型數(shù)據(jù)的常見(jiàn)陷阱與避免方法

    深入探討Python復(fù)合型數(shù)據(jù)的常見(jiàn)陷阱與避免方法

    在Python中,復(fù)合型數(shù)據(jù)(例如列表、元組、集合和字典)是非常常用的數(shù)據(jù)類(lèi)型,本文將深入探討Python復(fù)合型數(shù)據(jù)的常見(jiàn)陷阱,并提供一些避免這些問(wèn)題的實(shí)用建議和技巧,希望對(duì)大家有所幫助
    2024-03-03
  • python中的os.path.join使用方法詳解

    python中的os.path.join使用方法詳解

    這篇文章主要介紹了python中的os.path.join使用方法詳解,os.path.join用于將多個(gè)路徑拼接為一個(gè)完整路徑,經(jīng)常使用,但沒(méi)了解過(guò)細(xì)節(jié),直到今天遇到一個(gè)令人疑惑的問(wèn)題,最后發(fā)現(xiàn)是os.path.join的問(wèn)題,借此機(jī)會(huì),記錄下os.path.join的用法,需要的朋友可以參考下
    2023-11-11
  • python多進(jìn)程中的生產(chǎn)者和消費(fèi)者模型詳解

    python多進(jìn)程中的生產(chǎn)者和消費(fèi)者模型詳解

    這篇文章主要介紹了python多進(jìn)程中的生產(chǎn)者和消費(fèi)者模型,生產(chǎn)者是指生產(chǎn)數(shù)據(jù)的任務(wù),消費(fèi)者是指消費(fèi)數(shù)據(jù)的任務(wù)。當(dāng)生產(chǎn)者的生產(chǎn)能力遠(yuǎn)大于消費(fèi)者的消費(fèi)能力,生產(chǎn)者就需要等消費(fèi)者消費(fèi)完才能繼續(xù)生產(chǎn)新的數(shù)據(jù)
    2023-03-03
  • Pycharm打開(kāi)已有項(xiàng)目配置python環(huán)境的方法

    Pycharm打開(kāi)已有項(xiàng)目配置python環(huán)境的方法

    這篇文章主要介紹了Pycharm打開(kāi)已有項(xiàng)目配置python環(huán)境的方法,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2020-07-07
  • Python中修改字符串的四種方法

    Python中修改字符串的四種方法

    在Python中,字符串是不可變類(lèi)型,即無(wú)法直接修改字符串的某一位字符。這篇文章主要介紹了Python中修改字符串的四種方法,需要的朋友可以參考下
    2018-11-11
  • Python的turtle繪圖庫(kù)使用基礎(chǔ)

    Python的turtle繪圖庫(kù)使用基礎(chǔ)

    turtle庫(kù)是Python語(yǔ)言中一個(gè)很流行的繪制圖像的函數(shù)庫(kù),想象一個(gè)小烏龜,它根據(jù)一組函數(shù)指令的控制,在這個(gè)平面坐標(biāo)系中移動(dòng),從而在它爬行的路徑上繪制了圖形,需要的朋友可以參考下
    2023-04-04
  • 最大K個(gè)數(shù)問(wèn)題的Python版解法總結(jié)

    最大K個(gè)數(shù)問(wèn)題的Python版解法總結(jié)

    這篇文章主要介紹了最大K個(gè)數(shù)問(wèn)題的Python版解法總結(jié),以最大K個(gè)數(shù)問(wèn)題為基礎(chǔ)的算法題目在面試和各大考試及競(jìng)賽中經(jīng)常出現(xiàn),需要的朋友可以參考下
    2016-06-06

最新評(píng)論