發表文章

Angular中Router使用教學

圖片
Router 主要 Component   首先,在app.module.ts中加入Router module, 並建立Router規則,接著在@NgModule中加入routes 最後,在要使用Router的地方加入<router-outlet>,這裡我們在app.component.html中使用 接著,我們就可以使用<routerLink>變換<router-outlet>中的內容(對照前面routes<path, component>)

Mac + Home-brew + MySql 安裝

圖片
安裝: brew install mysql 啟動:brew services start mysql 設定:mysql_secure_installation 停止:brew services stop mysql 登入: mysql -u <username> -p

Java 自定義物件 排序 implements Comparable

定義物件 class Pair implements Comparable<Pair> { /* 自定義 object implements Comparable 42.07% */ int n ; int f ; public Pair ( int n , int f) { this . n = n ; this . f = f ; } public int compareTo (Pair o) { if ( this . f == o. f ) return o. n - this . n ; // desc return this . f - o. f ; // aces } }  之後排序可以使用 Collections. sort (l) ; 其中  List<Pair> l = new ArrayList<>() ;

Java 2d array sort(排序)

Arrays. sort (pairs , (a , b) -> { if (a[ 0 ] == b[ 0 ]) return a[ 1 ] - b[ 1 ] ; // if same strength, row aces else return a[ 0 ] - b[ 0 ] ; // normal, strength aces }) ;

Java 句號(.) split

 在java string 中如火想要正確的split 句號(.) 必須要使用 String.split("\\.") example: "leetcode.com".split("\\.");

MacOS + SDKMAN + JAVA

圖片
使用sdkman安裝多個不同版本的java 1. 安裝sdkman curl -s "https://get.sdkman.io" | bash 2. 顯示可安裝的java 版本 sdk  list java 3. 依照版本安裝 4. 切換java版本 5. java -version

Eclipse export WAR

  1. In Eclipse, stop Tomcat 2. Right-click your project and select Export > WAR File 3. In the Destination field, enter: <any-directory>/mycoolapp.war 4. Outside of Eclipse, start Tomcat - If you are using MS Windows, then you should find it on the Start menu 5. Make sure Tomcat is up and running by visiting: http://localhost:8080 6. Deploy your new WAR file by copying it to <tomcat-install-directory>\webapps Give it about 10-15 seconds to make the deployment. You'll know the deployment is over because you'll see a new folder created in webapps ... with your WAR file name. 7. Visit your new app. If your war file was: mycoolapp.war then you can access it with:  http://localhost:8080/mycoolapp/

MAC + Eclipse + Spring MVC Project

圖片
  This article shows how to create a spring MVC project. Environment: macOS(Monterey) + eclipse 2022 1. create a dynamic web project 2. convert to a maven project 3. setup spring MVC dependency 4. setup web.xml and spring.xml 5. write a controller 6. run on tomcat project structure shown below

Install Tomcat 10 on MacOS (Monterey)

Make sure you already install java on your machine. I'm using jenv to manage my java version. Installing Tomcat Here are the easy to follow steps to get it up and running on your Mac Download a binary distribution of the core module: apache-tomcat-10.0.21 from  here . I picked the  tar.gz  in Binary Distributions  Core  section. Opening/unarchiving the archive will create a new folder structure in your  Downloads  folder: (btw, this free  Unarchiver app  is perfect for all kinds of compressed files and superior to the built-in Archive Utility.app) ~/Downloads/apache-tomcat-10.0.21 Open the Terminal app to move the unarchived distribution to /usr/local like so: sudo mkdir -p /usr/local sudo mv ~/Downloads/apache-tomcat-10.0.21 /usr/local To make it easy to replace this release with future releases, we are going to create a symbolic link that we are going to use when referring to Tomcat (after removing the old link, you might have from installi...

Angular Form 沒有正常運作?

 !!!重要 在Angular中的Form  不需要使用Form標籤 否則會無法正常呼叫event 範例: <div class ="form-header" > <input # myInput class ="au-input au-input-xl" type ="text" placeholder ="keyword..." (keyup.enter) =" doSearch ( myInput . value ) " /> <button class ="au-btn-submit" type ="submit" (click) =" doSearch ( myInput . value ) " > Search </button> </div>

COCO-ANNOTATOR 使用心得(指令)

 !!!start up COCO-ANNOTATOR server!!! docker-compose up !!!stop COCO-ANNOTATOR server!!! docker-compose down delete all containers: docker rm $(docker ps -a -f status=exited -q) delete all images: docker rmi $(docker images -a -q) Deleting all the volumes: docker volume prune If you don't want to delete all the Docker volumes on your computer, you can search for a specific one and deleting it: docker volume ls docker volume rm <name_of_volume> under datasets folder: allow access in file chmod 777 *

Spring Boot +Jpa 报 Specified key was too long; max key length is 1000 bytes

  原因 Spring boot 2.x默认使用的mysql 引擎为myisam,但是Spring boot2.0之前使用的是InnoDB,Spring boot2.0之后默认使用的是myisam引擎。然后在新建表的时候。就出这个错了 解决 在配置文件中加如下配置: spring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialect

mac vi 常用指令

  在默认的”指令模式”下按 i 进入编辑模式 在非指令模式下按 ESC 返回指令模式 在”指令模式”下输入: :w 保存当前文件 :q 退出编辑,如果文件为保存需要用强制模式 :q! 强制退出不保存修改 :wq 组合指令, 保存并退出 在”指令模式”下移动: h 左 j 下 k 上 l 右

sublime3 常用快捷鍵

 ctrl+shift+p : 打開命令窗 ctrl+shift+space : 圈選括號內的內容

sublime3 安裝pretty json

圖片
  首先需要安装Package control,如果已经安装请跳过此步骤。按Ctrl+Shift+p打开命令框,搜索PCI,点击图中条目安装,如下图: 按 Ctrl+Shift+p 打开命令框,搜索PCI,打开package安装框 搜索PrettyJson,点击条目安装,如下图:

MMDetection中的操作

1. 训练 python tools/train.py [configs_file] --gpus 1 --work_dir work_dirs 2. 测试 (1)Output pkl file ​ This command will output “results_name.pkl” file. python tools/test.py [configs_file] [pth] --out results_name.pkl --eval bbox python tools/test.py configs/faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py checkpoints/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth --out=work_dirs/result.pkl --eval bbox (2) Output json result file ​ This command will output “results.bbox.json” file. python tools/test.py [configs_file] [pth] --eval-options "jsonfile_prefix=results_name" --eval bbox python tools/test.py configs/faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py checkpoints/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth --eval bbox --eval-options "jsonfile_prefix=results" 3. 输出coco metric python tools/analysis_tools/eval_metric.py [configs_file] [pkl_file] --eval bbox python tools/analysis_tools/eval_metric.py configs/faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py work_dirs/faster_rcn...

了解逆捲積的原理

圖片
  逆卷积的详细解释ConvTranspose2d(fractionally-strided convolutions) 1.首先先定义进行卷积的参数: 输入特征图为高宽一样的H in *H in 大小的x 卷积核大小kernel_size 步长stride padding填充数(填充0) 输出特征图为H out *H out 大小的y 计算式子为: H out  =  floor( H in  + 2*padding - kernel_size / stride) + 1   2.然后实现上面的卷积的转置卷积 定义其参数为:   输入特征图为高宽一样的H out *H out 大小的y 卷积核大小kernel_size 步长stride padding new  填充数(填充0) 输出特征图为H in *H in 大小的x   逆卷积的过程主要分两步: 对输入的特征图y进行变换,得到新的特征图y new 内部变换,与卷积时设置的stride相关 外部变换,与卷积时设置的padding相关 根据得到的特征图进行卷积即可 1)对输入的特征图y进行变换,得到新的特征图y new 1》内部变换 当卷积时设置的stride>1时,将对输入的特征图y进行插值操作(interpolation)。 即需要在输入的特征图y的每个相邻值之间插入(stride-1)行和列0,因为特征图中能够插入的相邻位置有(height-1)个位置,所以此时得到的特征图的大小由H out *H out (H out 即height) 变为新的 H out_new *H out_new ,即[H out  + (stride-1) * (H out -1)] * [H out  + (stride-1) * (H out -1)]   2》外部变换 为了实现由H out *H out 大小的y逆卷积得到H in *H in 大小的x,还需要设置padding new 的值为(kernel_size - padding - 1), 这里的padding是卷积操作时设置的padding值 所以计算式子变为: H in  =  floor( [H out_n...

File "pycocotools/_mask.pyx", line 307, in pycocotools._mask.frPyObjects Exception: input type is not supported.

 mmdetection在訓練有segmentation資料的時候,發生 File "pycocotools/_mask.pyx", line 307, in pycocotools._mask.frPyObjects Exception: input type is not supported. 主要原因為自製的segmentation資料中,可能有不符合規則的資料,coco格式中,segmentation的格式為list(list(x,y,x,y,....))每個seg至少要有四個值且必須為偶數。 下列code移除不符規定的seg def check_coco_seg_format(json_path):     """     check there is invalid segmentation data in coco json file and remove invalid seg then resave it     Args:         json_path: path to json file     Returns: None     """     with open(json_path) as fid:         json_data = json.load(fid)     annotations = json_data['annotations']     for annotation in tqdm(annotations):         segs = annotation['segmentation']         new_segs = []         for seg in segs:             len_seg = len(seg)       ...

AssertionError: Default process group is not initialized

 在訓練mmdetection可能會遇到的問題: AssertionError: Default process group is not initialized 此為分布式訓練在單cpu上的問題,將config的檔案中SyncBN修改為 BN 即可

如何在Colab使用soft link的效果?

圖片
 在Colab中如果想要使用soft link指令,並不支援,那要如何不複製出一份資料了? 在google drive中選擇要建立捷徑的檔案/目錄,按shift+Z,會出現一個新增捷徑的視窗 選擇想要的目的地,修改捷徑黨名,即可達到相同的效果