在为 tensorflow 模型设置环境时,当我python model_builder_test.py在最后一步运行时,原因AttributeError: module 'tensorflow' has no attribute 'float32',有人知道如何修复它吗?谢谢。
https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/installation.md
PS C:\Users\User\models\research\object_detection\builders> python model_builder_test.py
Traceback (most recent call last):
File "model_builder_test.py", line 21, in <module>
from object_detection.builders import model_builder
File "C:\Users\User\models\research\object_detection\builders\model_builder.py", line 17, in <module>
from object_detection.builders import anchor_generator_builder
File "C:\Users\User\models\research\object_detection\builders\anchor_generator_builder.py", line 18, in <module>
from object_detection.anchor_generators import grid_anchor_generator
File "C:\Users\User\models\research\object_detection\anchor_generators\grid_anchor_generator.py", line 27, in <module>
from object_detection.utils import ops
File "C:\Users\User\models\research\object_detection\utils\ops.py", line 282, in <module>
dtype=tf.float32):
AttributeError: module 'tensorflow' has no attribute 'float32'
Run Code Online (Sandbox Code Playgroud) 如果我有以下数据帧:
studentId sex history english math biology
01 male 75 90 85 60
02 female 85 80 95 70
03 male 55 60 78 86
04 male 90 89 76 80
Run Code Online (Sandbox Code Playgroud)
我想得到一张新表,显示每个科目分数的百分比高于80的阈值(包括80).例如,历史上有两个学生的分数高于80,因此历史的百分比是2/4 = 50%.有人可以用Python帮助我吗?谢谢.
history 50%
english 75%
math 50%
biology 50%
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用下面的链接中的代码来模糊图像中的人脸:
image = cv2.imread('45.jpg')
result_image = image.copy()
# Specify the trained cascade classifier
face_cascade_name = "?C:/Users/User/Desktop/haarcascade_frontalface_alt.xml"
# Create a cascade classifier
face_cascade = cv2.CascadeClassifier()
# Load the specified classifier
face_cascade.load(face_cascade_name)
#Preprocess the image
grayimg = cv2.cvtColor(image, cv2.COLOR_BGR2HSV)
grayimg = cv2.equalizeHist(grayimg)
#Run the classifiers
faces = face_cascade.detectMultiScale(grayimg, 1.1, 2, 0|cv2.cv.CV_HAAR_SCALE_IMAGE, (30, 30))
print ("Faces detected")
Run Code Online (Sandbox Code Playgroud)
但是我得到了如下的Traceback错误。请帮忙。谢谢。
Traceback (most recent call last):
File "<ipython-input-70-d20c79f10494>", line 15, in <module>
grayimg = cv2.equalizeHist(grayimg)
error: OpenCV(3.4.4) C:\projects\opencv-python\opencv\modules\imgproc\src\histogram.cpp:3334: error: (-215:Assertion failed) _src.type() == CV_8UC1 in …Run Code Online (Sandbox Code Playgroud) 我有以下数据帧:
import pandas as pd
import numpy as np
data = {
"index": [1, 2, 3, 4, 5],
"A": [11, 17, 5, 9, 10],
"B": [8, 6, 16, 17, 9],
"C": [10, 17, 12, 13, 15],
"target": [12, 13, 8, 6, 12]
}
df = pd.DataFrame.from_dict(data)
print(df)
Run Code Online (Sandbox Code Playgroud)
我想在A,B和C列中找到列目标的最接近值,并将这些值放入列结果中.据我所知,我需要使用abs()和argmin()函数.这是我预期的输出:
index A B C target result
0 1 11 8 10 12 11
1 2 17 6 17 13 17
2 3 5 16 12 8 5
3 4 9 17 13 …Run Code Online (Sandbox Code Playgroud) 我尝试使用Pythonmp4将目录中的大量文件合并test为一个文件。output.mp4ffmpeg
path = '/Users/x/Documents/test'
import os
for filename in os.listdir(path):
if filename.endswith(".mp4"):
print(filename)
Run Code Online (Sandbox Code Playgroud)
输出:
4. 04-unix,minix,Linux.mp4
6. 05-Linux.mp4
7. 06-ls.mp4
5. 04-unix.mp4
9. 08-command.mp4
1. 01-intro.mp4
3. 03-os.mp4
8. 07-minux.mp4
2. 02-os.mp4
10. 09-help.mp4
Run Code Online (Sandbox Code Playgroud)
我已经尝试使用以下参考中的解决方案:ffmpy concatenate multiple files with a file list
import os
import subprocess
import time
base_dir = "/path/to/the/files"
video_files = "video_list.txt"
output_file = "output.avi"
# where to seek the files
file_list = open(video_files, "w")
# remove prior output
try:
os.remove(output_file) …Run Code Online (Sandbox Code Playgroud) 我试图floor plan通过检测直线和边缘来检测许多图片的主要结构,参考here。
上面的例子是我需要处理的一个例子,是否可以通过检测线来获得主要结构opencv HoughLinesP?提前感谢您的帮助。
import cv2
import numpy as np
def get_lines(lines_in):
if cv2.__version__ < '3.0':
return lines_in[0]
return [l[0] for l in lines]
img = cv2.imread('./test.jpg', 1)
img_gray = gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
cannied = cv2.Canny(img_gray, threshold1=50, threshold2=200, apertureSize=3)
lines = cv2.HoughLinesP(cannied, rho=1, theta=np.pi / 180, threshold=80, minLineLength=30, maxLineGap=10)
for line in get_lines(lines):
leftx, boty, rightx, topy = line
cv2.line(img, (leftx, boty), (rightx,topy), (255, 255, 0), 2)
cv2.imwrite('./lines.png', img)
cv2.imwrite('./canniedHouse.png', cannied)
cv2.waitKey(0)
cv2.destroyAllWindows() …Run Code Online (Sandbox Code Playgroud) 如何将date格式为的列转换2014-09为格式2014-09-01 00:00:00.000?以前的格式是从df['date'] = pd.to_datetime(df['date']).dt.to_period("M").
我使用df['date'] = pd.to_datetime(df['date']).dt.strftime('%Y-%m-%d %H:%M:%S.000'),但它产生一个错误:TypeError: Passing PeriodDtype data is invalid. Use data.to_timestamp() instead。我也尝试使用pd.to_datetime(df['date']).dt.strftime('%Y-%m'),它会产生相同的错误。
我拥有的:
df
Name |Vehicle
Run Code Online (Sandbox Code Playgroud)
Dave |Car
Mark |Bike
Steve|Car
Dave |
Steve|
Run Code Online (Sandbox Code Playgroud)
我想从 Name 列中删除重复项,但前提是 Vehicle 列中的相应值为 null。我知道我可以使用
df.dropduplicates(subset=['Name'])
Run Code Online (Sandbox Code Playgroud)
使用任何Keep =一种,'First' or 'Last'但我正在寻找的是一种从Name列的相应值是 的Vehicle列中删除重复项的方法null。所以基本上,保留NameifVehicle列不为空并删除其余部分。如果名称没有重复,即使相应的值为Vehicle空,也保留该行。
非常感谢
我正在使用 statsmodels 的 arima 模型进行一些预测。这曾经很好地与
model_result = model.fit(disp = -1)
Run Code Online (Sandbox Code Playgroud)
但似乎 disp 似乎不再起作用 -
有没有人遇到过同样的问题并且知道 disp 的替代方案?如果没有这个,我就不可能合理地继续下去。
BR,谢谢你!
在一个目录下,我有多个具有相似格式的excel文件(您可以从这里下载示例文件):
我需要
read_excel(),name使用第二列名称改变新列,date和value,删除最后一列(其原始列名为1);do.call(rbind, df.list)我做了什么:
循环并获取文件路径:
library(fs)
folder_path <- './test/'
file_paths <- dir_ls(folder_path, regexp = ".xlsx")
Run Code Online (Sandbox Code Playgroud)
读取excel的函数:
read_excel_file <- function(path) {
df <- read_excel(path = path, header = TRUE)
}
Run Code Online (Sandbox Code Playgroud)
lapplyread_excel()函数到每个 Excel 文件:
df.list = lapply(file_paths, function(file) read_excel(file, skip = 2, col_names = FALSE))
df <- do.call(rbind, df.list)
Run Code Online (Sandbox Code Playgroud)
预期结果将是这样的数据框:
date value name
2 2021-01-07 -76.5 J05-J01
3 2021-01-08 -93.5 J05-J01
4 2021-01-15 …Run Code Online (Sandbox Code Playgroud) python ×9
pandas ×4
opencv ×2
contour ×1
dataframe ×1
datetime ×1
dplyr ×1
ffmpeg ×1
forecasting ×1
houghlinesp ×1
lapply ×1
r ×1
readxl ×1
statmodels ×1
subprocess ×1
tensorflow ×1
windows ×1