【Elasticsearch】-图片向量化存储

需要结合深度学习模型

1、pom依赖

注意结尾的webp-imageio 包,用于解决ImageIO.read读取部分图片返回为null的问题

<dependency><groupId>org.openpnp</groupId><artifactId>opencv</artifactId><version>4.7.0-0</version></dependency><dependency><groupId>com.microsoft.onnxruntime</groupId><artifactId>onnxruntime</artifactId><version>1.17.1</version></dependency><!-- 服务器端推理引擎 --><dependency><groupId>ai.djl</groupId><artifactId>api</artifactId><version>${djl.version}</version></dependency><dependency><groupId>ai.djl</groupId><artifactId>basicdataset</artifactId><version>${djl.version}</version></dependency><dependency><groupId>ai.djl</groupId><artifactId>model-zoo</artifactId><version>${djl.version}</version></dependency><!-- Pytorch --><dependency><groupId>ai.djl.pytorch</groupId><artifactId>pytorch-engine</artifactId><version>${djl.version}</version></dependency><dependency><groupId>ai.djl.pytorch</groupId><artifactId>pytorch-model-zoo</artifactId><version>${djl.version}</version></dependency><!-- ONNX --><dependency><groupId>ai.djl.onnxruntime</groupId><artifactId>onnxruntime-engine</artifactId><version>${djl.version}</version></dependency><!-- 解决ImageIO.read 读取为null --><dependency><groupId>org.sejda.imageio</groupId><artifactId>webp-imageio</artifactId><version>0.1.6</version></dependency>

2、加载模型

注意提前设置环境变量,pytorch依赖环境dll文件,如果不存在,则默认下载

System.setProperty("ENGINE_CACHE_DIR", modelPath);

import ai.djl.Device;
import ai.djl.modality.cv.Image;
import ai.djl.repository.zoo.Criteria;
import ai.djl.training.util.ProgressBar;
import ai.djl.translate.Translator;public Criteria<Image, T> criteria() {Translator<Image, T> translator = getTranslator(arguments);try {JarFileUtils.copyFileFromJar("/onnx/models/" + modelName, PathConstants.ONNX, null, false, true);} catch (IOException e) {throw new RuntimeException(e);}
//        String model_path = PathConstants.TEMP_DIR + PathConstants.ONNX + "/" + modelName;String modelPath = PathConstants.TEMP_DIR + File.separator+PathConstants.ONNX_NAME+ File.separator + modelName;log.info("路径修改前:{}",modelPath);modelPath= DjlHandlerUtil.getFixedModelPath(modelPath);log.info("路径修改后:{}",modelPath);Criteria<Image, T> criteria =Criteria.builder().setTypes(Image.class, getClassOfT()).optModelUrls(modelPath).optTranslator(translator).optDevice(Device.cpu()).optEngine(getEngine()) // Use PyTorch engine.optProgress(new ProgressBar()).build();return criteria;}protected Translator<Image, float[]> getTranslator(Map<String, Object> arguments) {BaseImageTranslator.BaseBuilder<?> builder=new BaseImageTranslator.BaseBuilder<BaseImageTranslator.BaseBuilder>() {@Overrideprotected BaseImageTranslator.BaseBuilder self() {return this;}};return new BaseImageTranslator<float[]>(builder) {@Overridepublic float[] processOutput(TranslatorContext translatorContext, NDList ndList) throws Exception {return ndList.get(0).toFloatArray();}};}

3、FaceFeatureTranslator

import ai.djl.modality.cv.Image;
import ai.djl.modality.cv.transform.Normalize;
import ai.djl.modality.cv.transform.ToTensor;
import ai.djl.ndarray.NDArray;
import ai.djl.ndarray.NDList;
import ai.djl.translate.Batchifier;
import ai.djl.translate.Pipeline;
import ai.djl.translate.Translator;
import ai.djl.translate.TranslatorContext;/*** @author gc.x* @date 2022-04*/
public final class FaceFeatureTranslator implements Translator<Image, float[]> {public FaceFeatureTranslator() {}@Overridepublic NDList processInput(TranslatorContext ctx, Image input) {NDArray array = input.toNDArray(ctx.getNDManager(), Image.Flag.COLOR);Pipeline pipeline = new Pipeline();pipeline// .add(new Resize(160)).add(new ToTensor()).add(new Normalize(new float[]{127.5f / 255.0f, 127.5f / 255.0f, 127.5f / 255.0f},new float[]{128.0f / 255.0f, 128.0f / 255.0f, 128.0f / 255.0f}));return pipeline.transform(new NDList(array));}@Overridepublic float[] processOutput(TranslatorContext ctx, NDList list) {NDList result = new NDList();long numOutputs = list.singletonOrThrow().getShape().get(0);for (int i = 0; i < numOutputs; i++) {result.add(list.singletonOrThrow().get(i));}float[][] embeddings = result.stream().map(NDArray::toFloatArray).toArray(float[][]::new);float[] feature = new float[embeddings.length];for (int i = 0; i < embeddings.length; i++) {feature[i] = embeddings[i][0];}return feature;}@Overridepublic Batchifier getBatchifier() {return Batchifier.STACK;}
}

4、BaseImageTranslator


import ai.djl.Model;
import ai.djl.modality.cv.Image;
import ai.djl.modality.cv.transform.CenterCrop;
import ai.djl.modality.cv.transform.Normalize;
import ai.djl.modality.cv.transform.Resize;
import ai.djl.modality.cv.transform.ToTensor;
import ai.djl.modality.cv.util.NDImageUtils;
import ai.djl.ndarray.NDArray;
import ai.djl.ndarray.NDList;
import ai.djl.translate.*;
import ai.djl.util.Utils;import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Arrays;
import java.util.List;
import java.util.Map;public abstract class BaseImageTranslator<T> implements Translator<Image, T> {private static final float[] MEAN = {0.485f, 0.456f, 0.406f};private static final float[] STD = {0.229f, 0.224f, 0.225f};private Image.Flag flag;private Pipeline pipeline;private Batchifier batchifier;/*** Constructs an ImageTranslator with the provided builder.** @param builder the data to build with*/public BaseImageTranslator(BaseBuilder<?> builder) {flag = builder.flag;pipeline = builder.pipeline;batchifier = builder.batchifier;}/** {@inheritDoc} */@Overridepublic Batchifier getBatchifier() {return batchifier;}/*** Processes the {@link Image} input and converts it to NDList.** @param ctx the toolkit that helps create the input NDArray* @param input the {@link Image} input* @return a {@link NDList}*/@Overridepublic NDList processInput(TranslatorContext ctx, Image input) {NDArray array = input.toNDArray(ctx.getNDManager(), flag);array = NDImageUtils.resize(array, 640, 640);array = array.transpose(2, 0, 1); // HWC -> CHW RGB -> BGR
//        array = array.expandDims(0);array = array.div(255f);return new NDList(array);
//        return pipeline.transform(new NDList(array));}protected static String getStringValue(Map<String, ?> arguments, String key, String def) {Object value = arguments.get(key);if (value == null) {return def;}return value.toString();}protected static int getIntValue(Map<String, ?> arguments, String key, int def) {Object value = arguments.get(key);if (value == null) {return def;}return (int) Double.parseDouble(value.toString());}protected static float getFloatValue(Map<String, ?> arguments, String key, float def) {Object value = arguments.get(key);if (value == null) {return def;}return (float) Double.parseDouble(value.toString());}protected static boolean getBooleanValue(Map<String, ?> arguments, String key, boolean def) {Object value = arguments.get(key);if (value == null) {return def;}return Boolean.parseBoolean(value.toString());}/*** A builder to extend for all classes extending the {@link BaseImageTranslator}.** @param <T> the concrete builder type*/@SuppressWarnings("rawtypes")public abstract static class BaseBuilder<T extends BaseBuilder> {protected int width = 224;protected int height = 224;protected Image.Flag flag = Image.Flag.COLOR;protected Pipeline pipeline;protected Batchifier batchifier = Batchifier.STACK;/*** Sets the optional {@link Image.Flag} (default is {@link* Image.Flag#COLOR}).** @param flag the color mode for the images* @return this builder*/public T optFlag(Image.Flag flag) {this.flag = flag;return self();}/*** Sets the {@link Pipeline} to use for pre-processing the image.** @param pipeline the pre-processing pipeline* @return this builder*/public T setPipeline(Pipeline pipeline) {this.pipeline = pipeline;return self();}/*** Adds the {@link Transform} to the {@link Pipeline} use for pre-processing the image.** @param transform the {@link Transform} to be added* @return this builder*/public T addTransform(Transform transform) {if (pipeline == null) {pipeline = new Pipeline();}pipeline.add(transform);return self();}/*** Sets the {@link Batchifier} for the {@link Translator}.** @param batchifier the {@link Batchifier} to be set* @return this builder*/public T optBatchifier(Batchifier batchifier) {this.batchifier = batchifier;return self();}protected abstract T self();protected void validate() {if (pipeline == null) {throw new IllegalArgumentException("pipeline is required.");}}protected void configPreProcess(Map<String, ?> arguments) {if (pipeline == null) {pipeline = new Pipeline();}width = getIntValue(arguments, "width", 224);height = getIntValue(arguments, "height", 224);if (arguments.containsKey("flag")) {flag = Image.Flag.valueOf(arguments.get("flag").toString());}if (getBooleanValue(arguments, "centerCrop", false)) {addTransform(new CenterCrop());}if (getBooleanValue(arguments, "resize", false)) {addTransform(new Resize(width, height));}if (getBooleanValue(arguments, "toTensor", true)) {addTransform(new ToTensor());}String normalize = getStringValue(arguments, "normalize", "false");if ("true".equals(normalize)) {addTransform(new Normalize(MEAN, STD));} else if (!"false".equals(normalize)) {String[] tokens = normalize.split("\\s*,\\s*");if (tokens.length != 6) {throw new IllegalArgumentException("Invalid normalize value: " + normalize);}float[] mean = {Float.parseFloat(tokens[0]),Float.parseFloat(tokens[1]),Float.parseFloat(tokens[2])};float[] std = {Float.parseFloat(tokens[3]),Float.parseFloat(tokens[4]),Float.parseFloat(tokens[5])};addTransform(new Normalize(mean, std));}String range = (String) arguments.get("range");if ("0,1".equals(range)) {addTransform(a -> a.div(255f));} else if ("-1,1".equals(range)) {addTransform(a -> a.div(128f).sub(1));}if (arguments.containsKey("batchifier")) {batchifier = Batchifier.fromString((String) arguments.get("batchifier"));}}protected void configPostProcess(Map<String, ?> arguments) {}}/** A Builder to construct a {@code ImageClassificationTranslator}. */@SuppressWarnings("rawtypes")public abstract static class ClassificationBuilder<T extends BaseBuilder>extends BaseBuilder<T> {protected SynsetLoader synsetLoader;/*** Sets the name of the synset file listing the potential classes for an image.** @param synsetArtifactName a file listing the potential classes for an image* @return the builder*/public T optSynsetArtifactName(String synsetArtifactName) {synsetLoader = new SynsetLoader(synsetArtifactName);return self();}/*** Sets the URL of the synset file.** @param synsetUrl the URL of the synset file* @return the builder*/public T optSynsetUrl(String synsetUrl) {try {this.synsetLoader = new SynsetLoader(new URL(synsetUrl));} catch (MalformedURLException e) {throw new IllegalArgumentException("Invalid synsetUrl: " + synsetUrl, e);}return self();}/*** Sets the potential classes for an image.** @param synset the potential classes for an image* @return the builder*/public T optSynset(List<String> synset) {synsetLoader = new SynsetLoader(synset);return self();}/** {@inheritDoc} */@Overrideprotected void validate() {super.validate();if (synsetLoader == null) {synsetLoader = new SynsetLoader("synset.txt");}}/** {@inheritDoc} */@Overrideprotected void configPostProcess(Map<String, ?> arguments) {String synset = (String) arguments.get("synset");if (synset != null) {optSynset(Arrays.asList(synset.split(",")));}String synsetUrl = (String) arguments.get("synsetUrl");if (synsetUrl != null) {optSynsetUrl(synsetUrl);}String synsetFileName = (String) arguments.get("synsetFileName");if (synsetFileName != null) {optSynsetArtifactName(synsetFileName);}}}protected static final class SynsetLoader {private String synsetFileName;private URL synsetUrl;private List<String> synset;public SynsetLoader(List<String> synset) {this.synset = synset;}public SynsetLoader(URL synsetUrl) {this.synsetUrl = synsetUrl;}public SynsetLoader(String synsetFileName) {this.synsetFileName = synsetFileName;}public List<String> load(Model model) throws IOException {if (synset != null) {return synset;} else if (synsetUrl != null) {try (InputStream is = synsetUrl.openStream()) {return Utils.readLines(is);}}return model.getArtifact(synsetFileName, Utils::readLines);}}
}

5、添加到ES

float[] feature;
// 构建文档Map<String, Object> dataMap = req.getDataMap();// 内置参数dataMap.put("_es_doc_type", "IMAGE");dataMap.put("vector", feature);IndexRequest<Map> request = IndexRequest.of(i -> i.index(req.getIndexLib()).id(req.getDocId()).document(dataMap));IndexResponse response = esClient.index(request);boolean flag = response.result() == Result.Created;log.info("添加文档id={},结果={}", req.getDocId(), flag);

6、pytorch环境依赖

cpu/linux-x86_64/native/lib/libc10.so.gz
cpu/linux-x86_64/native/lib/libtorch_cpu.so.gz
cpu/linux-x86_64/native/lib/libtorch.so.gz
cpu/linux-x86_64/native/lib/libgomp-52f2fd74.so.1.gz
cpu/osx-aarch64/native/lib/libtorch_cpu.dylib.gz
cpu/osx-aarch64/native/lib/libtorch.dylib.gz
cpu/osx-aarch64/native/lib/libc10.dylib.gz
cpu/osx-x86_64/native/lib/libtorch_cpu.dylib.gz
cpu/osx-x86_64/native/lib/libiomp5.dylib.gz
cpu/osx-x86_64/native/lib/libtorch.dylib.gz
cpu/osx-x86_64/native/lib/libc10.dylib.gz
cpu/win-x86_64/native/lib/torch.dll.gz
cpu/win-x86_64/native/lib/uv.dll.gz
cpu/win-x86_64/native/lib/torch_cpu.dll.gz
cpu/win-x86_64/native/lib/c10.dll.gz
cpu/win-x86_64/native/lib/fbgemm.dll.gz
cpu/win-x86_64/native/lib/libiomp5md.dll.gz
cpu/win-x86_64/native/lib/asmjit.dll.gz
cpu/win-x86_64/native/lib/libiompstubs5md.dll.gz
cpu-precxx11/linux-aarch64/native/lib/libc10.so.gz
cpu-precxx11/linux-aarch64/native/lib/libtorch_cpu.so.gz
cpu-precxx11/linux-aarch64/native/lib/libarm_compute-973e5a6b.so.gz
cpu-precxx11/linux-aarch64/native/lib/libopenblasp-r0-56e95da7.3.24.so.gz
cpu-precxx11/linux-aarch64/native/lib/libtorch.so.gz
cpu-precxx11/linux-aarch64/native/lib/libarm_compute_graph-6990f339.so.gz
cpu-precxx11/linux-aarch64/native/lib/libstdc%2B%2B.so.6.gz
cpu-precxx11/linux-aarch64/native/lib/libarm_compute_core-0793f69d.so.gz
cpu-precxx11/linux-aarch64/native/lib/libgfortran-b6d57c85.so.5.0.0.gz
cpu-precxx11/linux-aarch64/native/lib/libgomp-6e1a1d1b.so.1.0.0.gz
cpu-precxx11/linux-x86_64/native/lib/libgomp-a34b3233.so.1.gz
cpu-precxx11/linux-x86_64/native/lib/libc10.so.gz
cpu-precxx11/linux-x86_64/native/lib/libtorch_cpu.so.gz
cpu-precxx11/linux-x86_64/native/lib/libtorch.so.gz
cpu-precxx11/linux-x86_64/native/lib/libstdc%2B%2B.so.6.gz
cu121/linux-x86_64/native/lib/libc10_cuda.so.gz
cu121/linux-x86_64/native/lib/libcudnn.so.8.gz
cu121/linux-x86_64/native/lib/libnvfuser_codegen.so.gz
cu121/linux-x86_64/native/lib/libc10.so.gz
cu121/linux-x86_64/native/lib/libtorch_cpu.so.gz
cu121/linux-x86_64/native/lib/libcaffe2_nvrtc.so.gz
cu121/linux-x86_64/native/lib/libcudnn_adv_infer.so.8.gz
cu121/linux-x86_64/native/lib/libcudnn_cnn_train.so.8.gz
cu121/linux-x86_64/native/lib/libcudnn_ops_infer.so.8.gz
cu121/linux-x86_64/native/lib/libnvrtc-builtins-6c5639ce.so.12.1.gz
cu121/linux-x86_64/native/lib/libnvrtc-b51b459d.so.12.gz
cu121/linux-x86_64/native/lib/libtorch.so.gz
cu121/linux-x86_64/native/lib/libtorch_cuda_linalg.so.gz
cu121/linux-x86_64/native/lib/libcublas-37d11411.so.12.gz
cu121/linux-x86_64/native/lib/libtorch_cuda.so.gz
cu121/linux-x86_64/native/lib/libcudnn_adv_train.so.8.gz
cu121/linux-x86_64/native/lib/libcublasLt-f97bfc2c.so.12.gz
cu121/linux-x86_64/native/lib/libnvToolsExt-847d78f2.so.1.gz
cu121/linux-x86_64/native/lib/libcudnn_ops_train.so.8.gz
cu121/linux-x86_64/native/lib/libcudnn_cnn_infer.so.8.gz
cu121/linux-x86_64/native/lib/libgomp-52f2fd74.so.1.gz
cu121/linux-x86_64/native/lib/libcudart-9335f6a2.so.12.gz
cu121/win-x86_64/native/lib/zlibwapi.dll.gz
cu121/win-x86_64/native/lib/cudnn_ops_train64_8.dll.gz
cu121/win-x86_64/native/lib/torch.dll.gz
cu121/win-x86_64/native/lib/nvrtc-builtins64_121.dll.gz
cu121/win-x86_64/native/lib/cufftw64_11.dll.gz
cu121/win-x86_64/native/lib/cudnn_adv_infer64_8.dll.gz
cu121/win-x86_64/native/lib/nvrtc64_120_0.dll.gz
cu121/win-x86_64/native/lib/cusolverMg64_11.dll.gz
cu121/win-x86_64/native/lib/torch_cuda.dll.gz
cu121/win-x86_64/native/lib/cufft64_11.dll.gz
cu121/win-x86_64/native/lib/cublas64_12.dll.gz
cu121/win-x86_64/native/lib/cudnn64_8.dll.gz
cu121/win-x86_64/native/lib/uv.dll.gz
cu121/win-x86_64/native/lib/cudnn_cnn_train64_8.dll.gz
cu121/win-x86_64/native/lib/caffe2_nvrtc.dll.gz
cu121/win-x86_64/native/lib/torch_cpu.dll.gz
cu121/win-x86_64/native/lib/c10.dll.gz
cu121/win-x86_64/native/lib/cudnn_cnn_infer64_8.dll.gz
cu121/win-x86_64/native/lib/c10_cuda.dll.gz
cu121/win-x86_64/native/lib/cudart64_12.dll.gz
cu121/win-x86_64/native/lib/nvfuser_codegen.dll.gz
cu121/win-x86_64/native/lib/fbgemm.dll.gz
cu121/win-x86_64/native/lib/curand64_10.dll.gz
cu121/win-x86_64/native/lib/libiomp5md.dll.gz
cu121/win-x86_64/native/lib/cusolver64_11.dll.gz
cu121/win-x86_64/native/lib/cudnn_adv_train64_8.dll.gz
cu121/win-x86_64/native/lib/cublasLt64_12.dll.gz
cu121/win-x86_64/native/lib/nvToolsExt64_1.dll.gz
cu121/win-x86_64/native/lib/nvJitLink_120_0.dll.gz
cu121/win-x86_64/native/lib/cusparse64_12.dll.gz
cu121/win-x86_64/native/lib/asmjit.dll.gz
cu121/win-x86_64/native/lib/cudnn_ops_infer64_8.dll.gz
cu121/win-x86_64/native/lib/libiompstubs5md.dll.gz
cu121/win-x86_64/native/lib/cupti64_2023.1.1.dll.gz
cu121-precxx11/linux-x86_64/native/lib/libgomp-a34b3233.so.1.gz
cu121-precxx11/linux-x86_64/native/lib/libc10_cuda.so.gz
cu121-precxx11/linux-x86_64/native/lib/libcudnn.so.8.gz
cu121-precxx11/linux-x86_64/native/lib/libnvfuser_codegen.so.gz
cu121-precxx11/linux-x86_64/native/lib/libc10.so.gz
cu121-precxx11/linux-x86_64/native/lib/libtorch_cpu.so.gz
cu121-precxx11/linux-x86_64/native/lib/libcaffe2_nvrtc.so.gz
cu121-precxx11/linux-x86_64/native/lib/libcudnn_adv_infer.so.8.gz
cu121-precxx11/linux-x86_64/native/lib/libcudnn_cnn_train.so.8.gz
cu121-precxx11/linux-x86_64/native/lib/libcudnn_ops_infer.so.8.gz
cu121-precxx11/linux-x86_64/native/lib/libnvrtc-builtins-6c5639ce.so.12.1.gz
cu121-precxx11/linux-x86_64/native/lib/libnvrtc-b51b459d.so.12.gz
cu121-precxx11/linux-x86_64/native/lib/libtorch.so.gz
cu121-precxx11/linux-x86_64/native/lib/libtorch_cuda_linalg.so.gz
cu121-precxx11/linux-x86_64/native/lib/libcublas-37d11411.so.12.gz
cu121-precxx11/linux-x86_64/native/lib/libtorch_cuda.so.gz
cu121-precxx11/linux-x86_64/native/lib/libstdc%2B%2B.so.6.gz
cu121-precxx11/linux-x86_64/native/lib/libcudnn_adv_train.so.8.gz
cu121-precxx11/linux-x86_64/native/lib/libcublasLt-f97bfc2c.so.12.gz
cu121-precxx11/linux-x86_64/native/lib/libnvToolsExt-847d78f2.so.1.gz
cu121-precxx11/linux-x86_64/native/lib/libcudnn_ops_train.so.8.gz
cu121-precxx11/linux-x86_64/native/lib/libcudnn_cnn_infer.so.8.gz
cu121-precxx11/linux-x86_64/native/lib/libcudart-9335f6a2.so.12.gz
 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/bicheng/54373.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

docker存储

docker分层结构 如图所示&#xff0c;容器是由最上面可读可写的容器层&#xff0c;以及若干个只读镜像层组成&#xff0c;创建容器时&#xff0c;容器中的 数据都来自镜像层。这样的分层机构最大的特点是写时复制&#xff1a; 1、容器中新生成的数据会直接存放在容器层&#xf…

移动技术开发:登录注册界面

1 实验名称 登录注册界面 2 实验目的 掌握基本布局管理器的使用方法和基本控件的使用方法 3 实验源代码 布局文件代码&#xff1a; <?xml version"1.0" encoding"utf-8"?><LinearLayoutxmlns:android"http://schemas.android.com/apk/…

在Windows 7上安装Redis

1、下载Redis安装包‌&#xff1a; 首先&#xff0c;从Redis的官方网站或可信的第三方资源下载Redis的Windows版本安装包。确保下载与你的Windows 7系统兼容的版本。 2、解压安装包‌&#xff1a; 将下载的Redis安装包解压到你选择的目录&#xff0c;例如F:\Redis\redis-win…

关于文件操作

1. 为什么使⽤⽂件&#xff1f; 如果没有⽂件&#xff0c;我们写的程序的数据是存储在电脑的内存中&#xff0c;如果程序退出&#xff0c;内存回收&#xff0c;数据就丢失 了&#xff0c;等再次运⾏程序&#xff0c;是看不到上次程序的数据的&#xff0c;如果要将数据进⾏持久…

栈和队列的算法题目(C语言)

1. 括号匹配问题 20. 有效的括号 - 力扣&#xff08;LeetCode&#xff09; 利用栈后入先出的特性解题 1.判断字符串是否为空 为空返回 2.创建栈&#xff0c;遍历字符串 第一个字符是左括号的情况&#xff1a;入栈->继续遍历下一个字符 第一个字符是右括号的情况&#xf…

CAD图1

文章目录 选择直线工具选择圆形选中圆形 选择直线工具 画一条十字中心线 选择圆形 以十字中心为起点画一个半径为 53 的圆形 选中圆形 选中圆形&#xff0c;捕捉右侧圆形焦点

【算法专题】穷举vs暴搜vs深搜vs回溯vs剪枝

二叉树剪枝 LCR 047. 二叉树剪枝 - 力扣&#xff08;LeetCode&#xff09; 本题要求我们将全部为0的二叉树去掉&#xff0c;也就是剪枝&#xff0c;当我们举一个具体的例子进行模拟时&#xff0c;会发现&#xff0c;只关注于对其中一个子树的根节点进行剪枝&#xff0c;由于我…

4款AI生成PPT工具推荐,提升工作效率

在如今的工作环境中&#xff0c;PPT制作是许多技术人员不可避免的任务&#xff0c;尤其是在汇报、展示技术方案、以及项目进展时。随着AI技术的快速发展&#xff0c;使用AI生成PPT成为了提高效率的一种新趋势。本文将介绍几款适合程序员、技术人员的AI生成PPT工具&#xff0c;帮…

强化学习——马尔可夫决策过程(MDP)【附 python 代码】

一、马尔可夫过程 过程介绍随机过程在某时刻 t 的状态 S t S_t St​ 通常取决于 t 时刻之前的状态。状态 S t 1 S_{t1} St1​ 的概率表示为&#xff1a; P ( S t 1 ∣ S 1 , . . . , S t ) P(S_{t1}|S_1,...,S_t) P(St1​∣S1​,...,St​)马尔可夫过程某时刻 t 的状态只取…

JAVA-集合相关

HashMap如何解决哈希冲突的&#xff1f; 计算hash值&#xff0c;基于hashCode计算冲突之后&#xff0c;先是使用链式寻址法当链表长度大于8&#xff0c;且hash表的容量大于60的时候&#xff0c;再添加元素则转化成红黑树 为什么计算hash值是&#xff0c;是将hash地址的值右移1…

大数据Flink(一百一十八):Flink SQL水印操作(Watermark)

文章目录 Flink SQL水印操作&#xff08;Watermark&#xff09; 一、为什么要有WaterMark 二、​​​​​​​​​​​​​​Watermark解决的问题 三、​​​​​​​​​​​​​​代码演示 Flink SQL水印操作&#xff08;Watermark&#xff09; 一、​​​​​​​为什么…

43.常用C++编译器推荐——《跟老吕学C++》

43.常用C编译器推荐——《跟老吕学C》 常用C编译器推荐一、C编译器介绍1. GCC (GNU Compiler Collection)2. Clang2.1 Clang的特点2.2 Clang的应用场景2.3 Clang与GCC的比较 3. Microsoft Visual C (MSVC)MSVC的特点MSVC的使用场景MSVC与其他编译器的比较 4. Intel C Compiler4…

【Midjourney中文版】

Midjourney中文版打破了传统创作工具的界限&#xff0c;无需具备专业的艺术技能或复杂的软件操作能力&#xff0c;即可轻松创作出高质量的图片。它支持多种创作模式&#xff0c;包括文生图、图生图、图片混图融合等&#xff0c;满足多样化的创作需求。 打开Midjourney中文版后…

istio中如何使用serviceentry引入外部服务

假设需要引入一个外部服务&#xff0c;外部服务ip为10.10.102.90&#xff0c;端口为32033. 引入到istio中后&#xff0c;我想通过域名gindemo.test.ch:9090来访问这个服务。 serviceentry yaml内容如下&#xff1a; apiVersion: networking.istio.io/v1beta1 kind: ServiceEn…

【Pycharm】Pycharm创建Django提示pip版本需要升级

目录 1、现象 2、分析 3、本质 前言&#xff1a;经常使用pycharm创建django、flask等项目时候提示pip版本需要升级&#xff0c;解决方案 1、现象 使用Pycharm创建Django项目提示安装Django超时&#xff0c;报错建议pip升级22升级到24 2、分析 之前使用命令升级了pip到了24…

VS code EXPLORER 中不显示指定文件及文件夹设置(如.pyc, __pycache__, .vscode 文件)

VS code EXPLORER 中不显示指定文件及文件夹设置 引言正文方法1打开方式1打开方式2 方法2 引言 VS code 号称地表最强轻量级编译器&#xff0c;其最大的优势在于用户可以根据自己的需求下载适合自己的 extension。从而定制个性化的编译器。然而&#xff0c;本人今天遇到了一个…

出厂非澎湃OS手机解BL锁

脚本作者&#xff1a;酷安mlgmxyysd 脚本项目链接&#xff1a;https://github.com/MlgmXyysd/Xiaomi-HyperOS-BootLoader-Bypass/ 参考 B站作者&#xff1a;蓝空穹 https://www.bilibili.com/read/cv33210124/ 其他参考&#xff1a;云墨清风、水墨青竹、Magisk中文网 决定解BL…

设计模式 组合模式(Composite Pattern)

组合模式简绍 组合模式&#xff08;Composite Pattern&#xff09;是一种结构型设计模式&#xff0c;它允许你将对象组合成树形结构来表示“部分-整体”的层次结构。组合模式使得客户端可以用一致的方式处理单个对象和组合对象。这样&#xff0c;可以在不知道对象具体类型的条…

通信工程学习:什么是ONT光网络终端

ONT&#xff1a;光网络终端 ONT&#xff08;Optical Network Terminal&#xff0c;光网络终端&#xff09;是光纤接入网络&#xff08;FTTH&#xff09;中的关键设备&#xff0c;用于将光纤信号转换为电信号或将电信号转换为光信号&#xff0c;以实现用户设备与光纤网络的连接。…

Koa (下一代web框架) 【Node.js进阶】

koa (中文网) 是基于 Node.js 平台的下一代 web 开发框架&#xff0c;致力于成为应用和 API 开发领域中的一个更小、更富有表现力、更健壮的基石&#xff1b; 利用 async 函数 丢弃回调函数&#xff0c;并增强错误处理&#xff0c;koa 没有任何预置的中间件&#xff0c;可快速…