5 精币
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import cv2
import tensorflow as tf
from Modules.text.python.ops.text_ops import TextGeneration
# 加载图片并检测物体
img = cv2.imread('image.jpg' )
detector = cv2.dnn.readNetFromTensorflow('detectron_model.pb' )
classes, scores, boxes = detector.detect(img, 0.5 )
# 生成文本描述
text_gen = TextGeneration()
descriptions = []
for c, s, b in zip (classes, scores, boxes):
text = text_gen.describe_object(c, s, b)
descriptions.append(text)
# 构造 DFM 格式文本
dfm_text = '{"objects": ['
for c, s, b, desc in zip (classes, scores, boxes, descriptions):
dfm_text += '{"label":"' + str (c) + '", "conf":"' + str (s) + '", "bbox":"' + str (b) + '"},'
dfm_text = dfm_text.rstrip("," )
dfm_text += ']}'
# 输出到文件
with open ('dfm.txt' , 'w' ) as f:
f.write(dfm_text)
[size=13.0667px]无法加载文件 C:\Users\Administrator\PycharmProjects\code2\venv\Scripts\activate.ps1,因为在此系统上禁止运行脚本。有关详细信息,请参阅 https:/go.microsoft.com/fwlink/?LinkID=135170 中的 about_Execution_Policies。 + CategoryInfo : SecurityError: (:) [],ParentContainsErrorRecordException + FullyQualifiedErrorId : UnauthorizedAccess
[size=13.0667px]TextGeneration这个模块怎么调取啊
我来回答