91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 7.39MB
    文件類型: .gz
    金幣: 1
    下載: 0 次
    發(fā)布日期: 2023-10-22
  • 語(yǔ)言: Python
  • 標(biāo)簽: faster??rcnn??

資源簡(jiǎn)介

faster rcnn(python+caffe)

資源截圖

代碼片段和文件信息

//
//?This?script?converts?the?CIFAR?dataset?to?the?leveldb?format?used
//?by?caffe?to?perform?classification.
//?Usage:
//????convert_cifar_data?input_folder?output_db_file
//?The?CIFAR?dataset?could?be?downloaded?at
//????http://www.cs.toronto.edu/~kriz/cifar.html

#include???//?NOLINT(readability/streams)
#include?

#include?“boost/scoped_ptr.hpp“
#include?“glog/logging.h“
#include?“google/protobuf/text_format.h“
#include?“stdint.h“

#include?“caffe/proto/caffe.pb.h“
#include?“caffe/util/db.hpp“
#include?“caffe/util/format.hpp“

using?caffe::Datum;
using?boost::scoped_ptr;
using?std::string;
namespace?db?=?caffe::db;

const?int?kCIFARSize?=?32;
const?int?kCIFARImageNBytes?=?3072;
const?int?kCIFARBatchSize?=?10000;
const?int?kCIFARTrainBatches?=?5;

void?read_image(std::ifstream*?file?int*?label?char*?buffer)?{
??char?label_char;
??file->read(&label_char?1);
??*label?=?label_char;
??file->read(buffer?kCIFARImageNBytes);
??return;
}

void?convert_dataset(const?string&?input_folder?const?string&?output_folder
????const?string&?db_type)?{
??scoped_ptr?train_db(db::GetDB(db_type));
??train_db->Open(output_folder?+?“/cifar10_train_“?+?db_type?db::NEW);
??scoped_ptr?txn(train_db->NewTransaction());
??//?Data?buffer
??int?label;
??char?str_buffer[kCIFARImageNBytes];
??Datum?datum;
??datum.set_channels(3);
??datum.set_height(kCIFARSize);
??datum.set_width(kCIFARSize);

??LOG(INFO)?<??for?(int?fileid?=?0;?fileid?????//?Open?files
????LOG(INFO)?<????string?batchFileName?=?input_folder?+?“/data_batch_“
??????+?caffe::format_int(fileid+1)?+?“.bin“;
????std::ifstream?data_file(batchFileName.c_str()
????????std::ios::in?|?std::ios::binary);
????CHECK(data_file)?<????for?(int?itemid?=?0;?itemid???????read_image(&data_file?&label?str_buffer);
??????datum.set_label(label);
??????datum.set_data(str_buffer?kCIFARImageNBytes);
??????string?out;
??????CHECK(datum.SerializeToString(&out));
??????txn->Put(caffe::format_int(fileid?*?kCIFARBatchSize?+?itemid?5)?out);
????}
??}
??txn->Commit();
??train_db->Close();

??LOG(INFO)?<??scoped_ptr?test_db(db::GetDB(db_type));
??test_db->Open(output_folder?+?“/cifar10_test_“?+?db_type?db::NEW);
??txn.reset(test_db->NewTransaction());
??//?Open?files
??std::ifstream?data_file((input_folder?+?“/test_batch.bin“).c_str()
??????std::ios::in?|?std::ios::binary);
??CHECK(data_file)?<??for?(int?itemid?=?0;?itemid?????read_image(&data_file?&label?str_buffer);
????datum.set_label(label);
????datum.set_data(str_buffer?kCIFARImageNBytes);
????string?out;
????CHECK(datum.SerializeToString(&out));
????txn->Put(caffe::format_int(itemid?5)?out);
??}
??txn->Commit();
??test_db->Close();
}

int?main(int?argc?char**?ar

評(píng)論

共有 條評(píng)論