• 2012-11-10 19:18:00

Apache Buildr是类似Ruby Rake的Build System。 和我之前学习的Groovy Gradle很像。

准备在接下来的一段时间里加以学习。

这次先介绍如何安装buildr. 我之前已经有在自己的机器上安装过JRuby，所以这次就直接用JRuby来安装。

安装步骤也很简单：

jruby –S gem install buildr 即可。

可通过运行 buildr --verion来验证是否安装成功。

Ruby和JRuby分别维护者不同的Gem Repository,所以你也可以以Ruby的方式下去安装，这里就不多述了。

转载于:https://www.cnblogs.com/buhaiqing/archive/2012/11/10/2764378.html

更多相关内容
• Build EARBEAR）熊是一种工具，可生成用于clang工具的编译数据库。 在clang项目中使用JSON编译数据库来提供有关如何处理单个编译单元的信息。 机智构建EARBEARBear是一种工具，可为clang工具生成编译数据库。 ...
• ʔ·ᴥ·ʔ建立EAR Bear是一种工具，可生成用于clang工具的编译数据库。 在clang项目中使用来提供有关如何处理单个编译单元的信息。 这样，很容易用替代程序重新运行编译。 获取编译数据库的一种方法是使用cmake...
• bear插件报错 ld.so: object '/usr/${LIB}/bear/libear.so' from LD_PRELOAD bear -h usage: bear [-h] [--version] [--verbose] [--cdb <file>] [--use-cc <path>] [--use-c++ <path>] [--... # vscode开发，生成compile_commands.json ## bear插件报错 ### ld.so: object '/usr/${LIB}/bear/libear.so' from LD_PRELOAD

bear -h

usage: bear [-h] [--version] [--verbose] [--cdb <file>] [--use-cc <path>]
[--use-c++ <path>] [--append] [--libear LIBEAR]
...

positional arguments:
build                 Command to run.

optional arguments:
-h, --help            show this help message and exit
--version             show program's version number and exit
--verbose, -v         Enable verbose output from 'bear'. A second, third and
fourth flags increases verbosity. (default: 0)
--cdb <file>, -o <file>
The JSON compilation database. (default:
compile_commands.json)
--use-cc <path>       Hint 'bear' to classify the given program name as C
compiler. (default: cc)
--use-c++ <path>      Hint 'bear' to classify the given program name as C++
compiler. (default: c++)

--append, -a          Extend existing compilation database with new entries.
Duplicate entries are detected and not present in the
final output. The output is not continuously updated,
it's done when the build command finished. (default:
False)
--libear LIBEAR, -l LIBEAR
specify libear file location. (default:
/usr/\${LIB}/bear/libear.so)

# 解决方式

## find一下

find /usr/ -name "*bear*"

## 找到之后指导libbear路径

bear -l /usr/lib/x86_64-linux-gnu/bear/libear.so make -j4

展开全文
• frr-devtools 用于FRR的开发工具，脚本，配置文件等 目录清单 Bear-Build EAR的子模块，用于生成编译数据库 cocci-Coccinelle语义补丁 消毒-与ASAN / MSAN / TSAN相关的内容 脚本-安装脚本，重构脚本等
• 目录 How to Build the Confidence Habit Make friends with your failings and limitations Don’t be pushy or aggressive Don’t be defensive Do what you believe to be right ...

http://possibilitychange.com

目录

How to Build the Confidence Habit

Make friends with your failings and limitations

Don’t be pushy or aggressive

Don’t be defensive

Do what you believe to be right

Set challenging goals

Keep a record of your achievements

Learn to be optimistic

Take a balanced approach

Relax

7 Ways To Start To Value Yourself

1. Stop comparing yourself

2. Don’t settle

3. Start appreciating

4. Foster healthy relationships

5. Learn to say No

6. Set healthy boundaries

Becoming More Me Through Meditation

My anxiety is manageable, not curable.

Time for Self-Care is not Selfish.

Meditation Makes Difficult Moments Less Difficult

The Skeptic Became the Sales Pitch

I Am Not Afraid of Me

## How to Build the Confidence Habit

http://possibilitychange.com/build-confidence/

“If you hear a voice within you say “you cannot paint,” then by all means paint, and that voice will be silenced.”  – Vincent Van Gogh

We are all beset with doubts sometimes. Even the most self-assured and successful people can be unsure of themselves. Some people are clearly more confident than others, though. To what extent this is ‘nature’ and ‘nurture’ is unclear, though I suspect that ‘nurture’ has a lot to do with it. I’ve seen my own confidence wax and wane over the years, and external factors have certainly played a part. Some signs that you might be lacking somewhat in confidence are:

• Thinking that other people are better than you
• Expecting the worst outcome
• Engaging in negative self-talk
• Feeling the need to justify your behavior to others
• Overreacting to criticism
• Not having many friends or avoiding social situations
• Body language that is defensive and closed.

If you have some of these traits, perhaps you need to consider building more confidence. Can this be done? I think it’s clear is that confidence, like most other traits, can be developed. Like a muscle, with training and in time, it can become strong and powerful. To put it another way:confidence is a habit – confidence begets confidence. Here are some training ideas to develop this most important of habits.

### Make friends with your failings and limitations

This is a key area. Obviously, you are not perfect – far from it. So long as you are challenging yourself, stepping out of your comfort zone and seeking to develop, you will be making mistakes. The mistakes are signs of growth and nothing to be ashamed of.. Confident people are comfortable in their own skin, happy with themselves in all their imperfection. They have nothing to prove.

### Don’t be pushy or aggressive

Confidence can manifest itself in many different ways, and sometimes there is a visibly assertive quality to it, but there is also a quieter and more restrained confidence. When you meet a confident person, you tend to pick up that the person is happy with himself and feelscomfortable in her own skin. Confidence does not mean aggressive, pushy, loud or superior, which is often a sign of over-compensation for some kind of inferiority complex.

### Don’t be defensive

Listening to and acting on criticism is an important part of being confident. It is often very hard for us to be objective about ourselves, and other people can give us great insights into our strengths and weaknesses. Of course, we have to be critical about the things that people tell us, not falling into credulity and taking everything they say at face value. But the insights afforded by others can be very valuable. If people laugh at you or attack you, this probably says more about them than about you. Insecure people often try to cover up their feelings of inadequacy by falling into such behaviors.

### Do what you believe to be right

Confident people tend to rely on an internal guidance system to keep them going along the right track, whereas those with less confidence can be buffeted around by other people’s opinions and agendas. Having an inner compass is an essential part of living assertively and confidently, and following the compass can sometimes mean having to take risks. But without risk, there is no growth.

### Set challenging goals

Confident people tend to live in a more conscious and deliberate way, setting goals for themselves. They are secure enough to tolerate failure, and are comfortable with not getting things right first time. If we are not growing, then we are falling back – there is always movement. As we challenge ourselves, our comfort zone grows, and this growth often involves the pain of failure. This pain is too much for insecure people to bear. But to confident people, failure is only a stepping-stone, not the destination. Success, for confident people, is inevitable. It’s only a matter of time.

### Keep a record of your achievements

It is common for people with limited self-confidence to compare themselves unfavorably with others. Such people may assume that others are ‘better’ and have achieved more, so it can be very helpful to make a list of achievements. If you do this, you may find that the list is longer than you thought. Imagine what you would think if this were a list of someone else’s achievements. Would you be impressed? Would you think highly of that person?

### Learn to be optimistic

People who lack self-confidence are often pessimistic about the future and tend to think the worst. It’s important to replace negative, self-defeating mental chatter with upbeat, positive self-talk. All day long, thoughts are swirling around inside our head and we need to be conscious about this. Such self awareness isn’t easy, but with some gentle persistence you can become more aware of your thoughts and, when you catch yourself thinking in a negative way, replace the thought with something more positive. Examples of negative thinking are: exaggerating the negative aspects of things, taking things personally, feeling you are being blamed for things or feeling like a victim, to name just a few. Simply being aware of negative thinking modalities can be a great help in overcoming them. When you catch yourself thinking in such negative ways, try to replace the thought with something more self-affirming.

### Take a balanced approach

The benefits of confidence are clear but, as with most things, too much of it can be unhealthy. Over-confidence, which can lead to errors of judgment and under-performance, is dangerous and should be guarded against. Confidence is about getting the balance right.

### Relax

Confident people are more relaxed, happier and enjoy situations, however challenging, a lot more than those with low self-esteem, trusting that they can deal with whatever problems and challenges might arise. If you fail, if you get it all wrong, it won’t be the end of the world. If you’re tense and worried about how you’re being perceived, your energy is being wasted – it’s not going into the matter at hand. So let go, take the focus of attention off yourself, relax and enjoy the ride.

“Without a humble but reasonable confidence in your own powers you cannot be successful or happy.”  ~ Norman Vincent Peale

The benefits of being confident are clear: you’ll be happier, more relaxed and probably healthier. You’ll use time more effectively because you won’t be worrying endlessly about other people’s opinions, and you’ll have a clearer sense of purpose, so you’ll be a lot more effective. Confidence, in a sense, is the key to happiness and fulfillment.

“What a fool am I, thus to lie in a stinking dungeon, when I may as well walk at liberty!  I have a key in my bosom, called Promise, that will, I am persuaded, open any lock in Doubting Castle.” – John Bunyan

Photo by Andy C

## 7 Ways To Start To Value Yourself

“You can search throughout the entire universe for someone who is more deserving of your love and affection than you are yourself, and that person is not to be found anywhere. You, yourself, as much as anybody in the universe, deserve your love and affection” – Buddha

One of the biggest myths we feed into is that setting ourselves as a number one priority is selfish and unkind. Truth is, it is the most loving thing we can do for ourselves and for others. Our loved ones gain when we are in a good space and when we have all our energy at any given moment. People benefit when we are whole and life opens when we are thriving. Yet, we’re so conditioned to believe that things will fall apart and it is not ethical to put the person who lives inside your heart, body, and mind first.

I remember before I met my husband, I started to pull back from some toxic relationships in my life. I allowed myself to be taken advantage of; let myself be taken for granted. They demanded so much but gave so little. My time, my finances, my heartfelt, “I will stretch until I break, as long as you don’t have discomfort.”

When my priorities shifted and I started giving a little more love to me. Not only did it feel amazing, but I had to have this love within me before I could give it freely to someone else. My new found happiness was poorly wished upon. And instead of attempting to fix those relationships, I stood my ground with “I am loveable and worthy” mantras. I focused on the blossoming relationships and let go of the suffocating.

Making yourself a priority enables you to be a better person, not just for yourself, but for the relationships your forge along the way. The choices we make from a more loving space are far more beneficial than the ones we make from a place of guilt, lack and overextending.

Below are seven ways to start to value yourself and make yourself an important person in your life. Besides, everything starts with you.

### 1. Stop comparing yourself

Comparing ourselves to others is a losing battle. Not only do we look for things we lack, but we find ourselves in the feeling of lack. Unless you have been in their shoes, view life the way they do and gone through their experiences, you are comparing yourself to information that can in no way be accurate. Comparing takes the focus off you and onto that person, yet your power lies in things you can affect in your life. You are a unique being and there is nobody in the world like you.

Start to shift your focus on things that are going right in your life and pay attention to the person looking back in the mirror. He or she has their own unique attributes. Let go of the inner perfectionist and start to appreciate your smile, your talents, what you have to offer. Starting to see your value is the fastest way to shift focus to the right place.

### 2. Don’t settle

Some people stay in jobs they don’t like just because of the salary. Others settle in relationships that no longer cause their hearts to race. Some of us stay with friends who deplete us because we long for any kind of company. Whatever your settle, it’s not worth the cost. You deserve peace of mind and to be outrageously happy.

If you are constantly saying to yourself, “There has to be something better than this”, you are probably settling. Don’t settle for less. Seek out to find your best.

### 3. Start appreciating

Appreciate the bed you sleep it. Appreciate your significant other. Appreciate the clothes you have on your back, your car, your food. But mostly, don’t forget to appreciate what you bring into the world. Start to see the joy you bring to others. Give thought to the impact of that joy and its ripple effects. Just because you are not aware, does not mean it has not extended itself further than you can imagine.

The more you appreciate, the more good will flow into your life.

### 4. Foster healthy relationships

Let go of or at least distance yourself from anything that causes you to feel less than good. Find yourself in the presence of people who bring something significant into your life. Make it a point to have at least two people who feed your spirit, encourage your dreams and accept you for who you are. No alterations. Cultivating strong, nurturing bonds encourages us to remember we are not alone and keeps our hearts open.

### 5. Learn to say No

While we are here to help one another there will be times we’re tempted to do things at the expense of our own well-being. Sometimes when we give more than we can we don’t allow the other person to learn from or have their own experiences. Continually doing things out of insincere obligation can lead to resentment. Instead, honor yourself by doing what feels right for you.

‘No’ can be liberating, because when we say no to others we are saying “yes” to ourselves and we’re in alignment with our values. Allow yourself to say no once in a while. This practice will improve your self-esteem and create a space for people to value and respect you more.

### 6. Set healthy boundaries

Having clear boundaries is vital to establishing that relationships are mutually respectful. Believe it or not, but putting “up” boundaries actually creates freedom because when our wishes are clearly defined, there is no need to put up walls. Boundaries reflect our self-esteem and our values. A healthy self-respect will teach others how to treat you.

And when the occasional person attempts to push against your lines, simply keep your feet placed firmly on the ground.

We all have something that makes us come alive and gives our lives meaning. Don’t forget to listen to the part of you that drives your bliss, and be aware of your idol wants and those little things that distract you. Focus on your purpose because dreams never really go away. They simply get postponed.

Our passions can be as little or big as they are, and we can have one or a multitude of them. Listen to the things that are ticking at your heart’s door and find a way to do one thing at a time if you can. You can encourage yourself to do it all and to find a way for life to support you while you do.

Everything in our lives starts with us and ripples into our relationships. So it only makes sense to give yourself as much love, nurturing and joy that you would look for in others, or that others would seek in you. By living the best life we can we inject these ripples to go out with love, beauty, and kindness.

## Becoming More Me Through Meditation

“The thing about meditation is: You become more and more you.” — David Lynch

The thing about my meditation experience is this:  I was terrified of what it meant to become more me.  When I agreed at the urging of a very patient therapist to at least attempt to meditate, I was truly afraid of what was underneath the layers of self-preservation I had built up.  It was my thirty-fifth birthday and my gift to myself was to commit to anything that might improve my anxiety.

Up to that point, I had tried reading self-help books, running, yoga, and even prescription medication.  Like clockwork, though, I could expect an anxiety attack around 2:30PM and again around 8:00PM, times when my mind became less engaged in work and productive thoughts.  Scrambling, circular thoughts precipitated the inability to take a deep breath and the combination led to reaching out like a person drowning for any validation I could find from friends and family.

Anxiety had been a part of my life since childhood, but as I watched my thirty-fifth birthday approach, I decided that I was otherwise happy enough and managing my anxiety was the only thing I would change.

Before my first therapy appointment, I committed to trying anything she suggested.  “How often do you meditate?” was the first question she asked.

“I don’t”  I replied, and she made a note, and advised that I would learn.

I committed to meditating for at least five minutes every day.  At the end of my run in the evenings, I walked down to a pond in my neighborhood with nothing more than my cell phone and a pair of ear buds and sat staring at the water listening to a guided meditation and fighting skepticism.

Not every day’s meditation went well.  Some days I was able to reach an easy Zen-like state quickly and stay there.  Some days I sat and worried that neighbors would think I was some sort of hippy if I stared at the water too long.  Somehow, though, five minutes became ten, then fifteen.  A daily meditation practice became a twice-daily meditation.

There’s plenty of room for improvement and I’m excited to learn more about meditation, and for the first time, I’m excited to learn more about myself.  After six weeks, I’m startled at the changes meditation has had in my life.

### My anxiety is manageable, not curable.

Anxiety will always be a part of me, but it doesn’t have to define me.  After only six weeks of regular practice, my anxiety attacks are noticeably dwindling.  I’m learning to breathe through those moments when troubled thoughts do arise, and some days I look at the clock and realize an entire day has passed without one anxiety attack.  I’m not naïve enough to think I’m cured—I don’t believe anxiety has a cure.  I am optimistic to think I’ve learned a natural, holistic way to manage anxiety.

I’m still in the honeymoon-phase of meditation, but I can already sense that it has to be a daily practice and not just something I can turn to when I need it.  I can feel myself start to slip when I don’t practice with an intention.

### Time for Self-Care is not Selfish.

I could have made time for a party I was invited to on a Saturday night, but there was something feeling just a little off.  I knew I would be better served by spending some time in solitude and making more time to meditate.  I declined the invitation and stayed home, knowing instinctively that I had made the right decision for me, but I had to fight through habitual feelings of guilt.  That’s a habit I’m trying to break, and given how much better I felt the next day, I know I made the right decision.  It’s not a selfish act to spend time in solitude and to practice self-care.

### Meditation Makes Difficult Moments Less Difficult

My doctor was pleasantly surprised to find my blood pressure had significantly improved after six weeks of changing nothing more than adding a twice daily meditation practice.  I was pleasantly surprised to find that my relationships, my running regimen, and my career also suddenly felt far less challenging and stressful.

My anxiety was no longer allowed to make decisions either in my relationships or in my career, and subsequently, my stress reduced and my productivity increased.  Challenging moments passed without creating an anxiety attack, and I began to operate from a centered place of authenticity instead of responding to every whim of my anxiety.

Anxiety had been making decisions for far too long.  I had allowed anxiety to do so because it was easier, I thought, than scraping away the layers of self-doubt and insecurity to do what was right for me.  With anxiety lulled into a safe place through meditation, I am making more secure, more confident, and acting on my own behalf.

### The Skeptic Became the Sales Pitch

“You should meditate,” I hear myself saying on a daily basis.  “Yes, you can, everyone can meditate!”  Who is this person?  Six weeks ago, I was the one trying to convince a therapist that I couldn’t meditate.  Now no one is immune from my sales pitch for meditation.  If coworkers complain to me that they can’t get enough sleep, I urge them to meditate.  A friend in crisis wants to vent in a telephone call, and I urge her to meditate.  I know that by now they’ve seen the change in me and I’m so desperate for others to take the fifteen-minute mental break that will help them that I am a broken record urging all who cross my path to breathe deep and let it go.

### I Am Not Afraid of Me

I’ve come to the realization that my anxiety is rooted in the resistance I have built to feeling my feelings.  At the first sign of circular thinking and shortness of breath now, I zone in on how I’m feeling and why I’m feeling that emotion.  I don’t run.  I don’t put up a wall.  I let it pass over me, I acknowledge the feeling and if I can change it, I do.  If I can’t change the circumstances of the emotion, I let myself feel it.

I was terrified of meditation when I started because I didn’t want to know what was under the protective layers of emotional scar tissue I had created to avoid feeling unpleasant emotions.  There are still difficult days when I realize that there’s an ugly bruise of emotion that I failed to properly address when it was happening.  But I’m not afraid.  This is me.  I am a collaboration of every memory, moment and emotion that has already happened.  I’m not yet quite fearless, but I am no longer afraid to sit with myself, allow an emotion, and dive into the messy, wondrous beauty of my own mind.

This is my journey at six weeks.  Where are you in your journey and what unexpected epiphanies await?

展开全文
• ## PyTorch：生态简介

千次阅读 2022-03-24 12:48:27
'toaster', 'sink', 'refrigerator', 'N/A', 'book','clock', 'vase', 'scissors', 'teddy bear', 'hair drier', 'toothbrush'] COCO_PERSON_KEYPOINT_NAMES =['nose','left_eye','right_eye','left_ear','right_ear...

## PyTorch生态简介

PyTorch的强大并不仅局限于自身的易用性，更在于开源社区围绕PyTorch所产生的一系列工具包（一般是Python package）和程序，这些优秀的工具包极大地方便了PyTorch在特定领域的使用。

比如对于计算机视觉，有TorchVision、TorchVideo等用于图片和视频处理；

对于自然语言处理，有torchtext；

对于图卷积网络，有PyTorch Geometric等。

这里只是举例，每个领域还有很多优秀的工具包供社区使用。

这些工具包共同构成了PyTorch的生态（EcoSystem）。

PyTorch生态很大程度助力了PyTorch的推广与成功。在特定领域使用PyTorch生态中的工具包，能够极大地降低入门门槛，方便复现已有的工作。

比如我们在讨论模型修改时候就用到了torchvision中预定义的resnet结构，而不需要自己重新编写。

同时，PyTorch生态有助于社区力量的加入，共同为社区提供更有价值的内容和程序，这也是开源理念所坚持的价值。

## 图像 torchvision

在前面的学习和实战中，我们经常会用到torchvision来调用预训练模型，加载数据集，对图片进行数据增强的操作。在本章将给大家简单介绍下torchvision以及相关操作。

经过本节的学习，将收获：

• 了解torchvision
• 了解torchvision的作用

### torchvison简介

" The torchvision package consists of popular datasets, model architectures, and common image transformations for computer vision. "

正如引言介绍的一样，我们可以知道torchvision包含了在计算机视觉中常常用到的数据集，模型和图像处理的方式，而具体的torchvision则包括了下面这几部分，带*的部分是经常会使用到的一些库，所以在下面的部分对这些库进行一个简单的介绍：

• torchvision.datasets *
• torchvision.models *
• torchvision.tramsforms *
• torchvision.ops
• torchvision.utils

### torchvision.datasets

torchvision.datasets主要包含了一些我们在计算机视觉中常见的数据集，在0.10.0版本的torchvision下，有以下的数据集：

https://pytorch.org/vision/stable/datasets.html

#### 图像分类

• Caltech101
• Caltech256
• CelebA
• CIFAR10
• CIFAR100
• Country211
• DTD
• EMNIST
• EuroSAT
• FakeData
• FashionMNIST
• FER2013
• FGVCAircraft
• Flickr8k
• Flickr30k
• Flowers102
• Food101
• GTSRB
• INaturalist
• ImageNet
• KMNIST
• LFWPeople
• LSUN
• MNIST
• Omniglot
• OxfordIIITPet
• Places365
• PCAM
• QMNIST
• RenderedSST2
• SEMEION
• SBU
• StanfordCars
• STL10
• SUN397
• SVHN
• USPS

#### 图像检测与分割

• CocoDetection
• CelebA
• Cityscapes
• GTSRB
• Kitti
• OxfordIIITPet
• SBDataset
• VOCSegmentation
• VOCDetection
• WIDERFace

#### 光流

• FlyingChairs
• FlyingThings3D
• HD1K
• KittiFlow
• Sintel

• LFWPairs
• PhotoTour

#### 图像标题

• CocoCaptions

#### 视频分类

• HMDB51
• Kinetics
• Kinetics400
• UCF101

### torchvision.transforms

在计算机视觉中处理的数据集有很大一部分是图片类型的，如果获取的数据是格式或者大小不一的图片，则需要进行归一化和大小缩放等操作，这些是常用的数据预处理方法。

除此之外，当图片数据有限时，还需要通过对现有图片数据进行各种变换，如缩小或放大、水平或垂直翻转等，这些是常见的数据增强方法。

torchvision.transforms中就包含了许多这样的操作。

from torchvision import transforms

image_size = (224, 224)

data_transform = transforms.Compose([
transforms.ToPILImage(),   # 这一步取决于后续的数据读取方式，如果使用内置数据集则不需要
transforms.Resize(image_size),
transforms.ToTensor()
])


除了上面提到的几种数据增强操作，在torchvision官方文档里提到了更多的操作，更多数据变换的操作查看
https://pytorch.org/vision/stable/transforms.html

### torchvision.models

为了提高训练效率，减少不必要的重复劳动，PyTorch官方也提供了一些预训练好的模型供使用。

可以https://github.com/pytorch/vision/tree/main/torchvision/models这里进行查看现在有哪些预训练模型，下面将对如何使用这些模型进行详细介绍。 此处以torchvision0.10.0 为例，如果希望获取更多的预训练模型，可以使用使用pretrained-models.pytorch仓库。

现有预训练好的模型可以分为以下几类：

#### 图像分类

在图像分类里面，PyTorch官方提供了以下模型，并正在不断增多。

• AlexNet
• VGG
• ResNet
• SqueezeNet
• DenseNet
• Inception v3
• ShuffleNet v2
• MobileNetV2
• MobileNetV3
• ResNeXt
• Wide ResNet
• MNASNet
• EfficientNet
• RegNet
• VisionTransformer
• ConvNeXt

这些模型是在ImageNet-1k进行预训练好的，具体的使用在之前有过介绍。

除此之外，也可以点击https://pytorch.org/vision/stable/models.html#去查看这些模型在ImageNet-1k的准确率。

#### 语义分割

语义分割的预训练模型是在COCO train2017的子集上进行训练的，提供了20个类别，包括
background, aeroplane, bicycle, bird, boat, bottle, bus, car, cat, chair, cow, diningtable, dog, horse, motorbike, person, pottedplant, sheep, sofa,train, tvmonitor

模型有：

• FCN ResNet50, ResNet101
• DeepLabV3 ResNet50, ResNet101, MobileNetV3-Large
• LR-ASPP MobileNetV3-Large

具体我们可以点击https://pytorch.org/vision/stable/models.html#semantic-segmentation进行查看预训练的模型的mean IOU和 global pixelwise acc

#### 目标检测，实例分割与关键点检测

物体检测，实例分割和人体关键点检测的模型同样是在COCO train2017进行训练的，在下方提供了实例分割的类别和人体关键点检测类别：

COCO_INSTANCE_CATEGORY_NAMES = [
'__background__', 'person', 'bicycle', 'car', 'motorcycle', 'airplane', 'bus','train', 'truck', 'boat', 'traffic light', 'fire hydrant', 'N/A', 'stop sign', 'parking meter', 'bench', 'bird', 'cat', 'dog', 'horse', 'sheep', 'cow', 'elephant', 'bear', 'zebra', 'giraffe', 'N/A', 'backpack', 'umbrella', 'N/A', 'N/A','handbag', 'tie', 'suitcase', 'frisbee', 'skis', 'snowboard', 'sports ball','kite', 'baseball bat', 'baseball glove', 'skateboard', 'surfboard', 'tennis racket','bottle', 'N/A', 'wine glass', 'cup', 'fork', 'knife', 'spoon', 'bowl','banana', 'apple', 'sandwich', 'orange', 'broccoli', 'carrot', 'hot dog', 'pizza','donut', 'cake', 'chair', 'couch', 'potted plant', 'bed', 'N/A', 'dining table','N/A', 'N/A', 'toilet', 'N/A', 'tv', 'laptop', 'mouse', 'remote', 'keyboard', 'cell phone','microwave', 'oven', 'toaster', 'sink', 'refrigerator', 'N/A', 'book','clock', 'vase', 'scissors', 'teddy bear', 'hair drier', 'toothbrush']

COCO_PERSON_KEYPOINT_NAMES =['nose','left_eye','right_eye','left_ear','right_ear','left_shoulder','right_shoulder','left_elbow','right_elbow','left_wrist','right_wrist','left_hip','right_hip','left_knee','right_knee','left_ankle','right_ankle']


模型有：

• Faster R-CNN
• FCOS
• RetinaNet
• SSD
• SSDlite

同样的，可以点击https://github.com/datawhalechina/thorough-pytorch/blob/main/%E7%AC%AC%E5%85%AB%E7%AB%A0%20PyTorch%E7%94%9F%E6%80%81%E7%AE%80%E4%BB%8B/8.2%20%E5%9B%BE%E5%83%8F%20-%20torchvision.md查看这些模型在COCO train 2017上的box AP,keypoint AP,mask AP

#### torchvision.io

torchvision.io提供了视频、图片和文件的 IO 操作的功能，它们包括读取、写入、编解码处理操作。

随着torchvision的发展，io也增加了更多底层的高效率的API。

在使用torchvision.io的过程中，需要注意以下几点：

• 不同版本之间，torchvision.io有着较大变化，因此在使用时，需要查看下torchvision版本是否存在想使用的方法
• 除了read_video()等方法，torchvision.io提供了一个细粒度的视频API torchvision.io.VideoReader() ，它具有更高的效率并且更加接近底层处理。在使用时，需要先安装ffmpeg, 然后从源码重新编译torchvision才能使用这些方法
• 在使用Video相关API时，最好提前安装好PyAV这个库

#### torchvision.ops

torchvision.ops 提供了许多计算机视觉的特定操作

包括但不仅限于NMSRoIAlign（MASK R-CNN中应用的一种方法），RoIPool（Fast R-CNN中用到的一种方法）。

在合适的时间使用可以大大降低工作量，避免重复的造轮子

想看更多的函数介绍可以点击https://pytorch.org/vision/stable/ops.html进行细致查看。

#### torchvision.utils

torchvision.utils 提供了一些可视化的方法，可以将若干张图片拼接在一起、可视化检测和分割的效果。

具体方法可以点击https://pytorch.org/vision/stable/utils.html进行查看。

#### 总结

torchvision的出现帮助我们解决了常见的计算机视觉中一些重复且耗时的工作，并在数据集的获取、数据增强、模型预训练等方面大大降低了工作难度，可以让更加快速上手一些计算机视觉任务。

## PyTorchVideo简介

近几年来，随着传播媒介和视频平台的发展，视频正在取代图片成为下一代的主流媒体，这也使得有关视频的深度学习模型正在获得越来越多的关注。然而，有关视频的深度学习模型仍然有着许多缺点：

• 计算资源耗费更多，并且没有高质量的model zoo，不能像图片一样进行迁移学习和论文复现
• 数据集处理较麻烦，但没有一个很好的视频处理工具
• 随着多模态越来越流行，亟需一个工具来处理其他模态

PyTorchVideo 是一个专注于视频理解工作的深度学习库。PytorchVideo 提供了加速视频理解研究所需的可重用、模块化和高效的组件。PyTorchVideo 是使用PyTorch开发的，支持不同的深度学习视频组件，如视频模型、视频数据集和视频特定转换。

### PyTorchVideo的主要部件和亮点

PytorchVideo 提供了加速视频理解研究所需的模块化和高效的API。它还支持不同的深度学习视频组件，如视频模型、视频数据集和视频特定转换，最重要的是，PytorchVideo也提供了model zoo，使得人们可以使用各种先进的预训练视频模型及其评判基准。PyTorchVideo主要亮点如下：

• 基于 PyTorch： 使用 PyTorch 构建。使所有 PyTorch 生态系统组件的使用变得容易
• Model Zoo： PyTorchVideo提供了包含I3D、R(2+1)D、SlowFast、X3D、MViT等SOTA模型的高质量model zoo（目前还在快速扩充中，未来会有更多SOTA model），并且PyTorchVideo的model zoo调用与PyTorch Hub做了整合，大大简化模型调用
• 数据预处理和常见数据：，PyTorchVideo支持Kinetics-400, Something-Something V2, Charades, Ava (v2.2), Epic Kitchen, HMDB51, UCF101, Domsev等主流数据集和相应的数据预处理，同时还支持randaug, augmix等数据增强trick
• 模块化设计： PyTorchVideo的设计类似于torchvision，也是提供许多模块方便用户调用修改，在PyTorchVideo中具体来说包括data, transforms, layer, model, accelerator等模块，方便用户进行调用和读取
• 支持多模态： PyTorchVideo现在对多模态的支持包括了visual和audio，未来会支持更多模态，为多模态模型的发展提供支持
• 移动端部署优化： PyTorchVideo支持针对移动端模型的部署优化（使用前述的PyTorchVideo/accelerator模块），模型经过PyTorchVideo优化了最高达7倍的提速，并实现了第一个能实时跑在手机端的X3D模型（实验中可以实时跑在2018年的三星Galaxy S8上，具体请见Android Demo APP）

### PyTorchVideo的安装

可以直接使用pip来安装PyTorchVideo：

pip install PyTorchVideo


注：

• 安装的虚拟环境的python版本 >= 3.7
• PyTorch >= 1.8.0，安装的torchvision也需要匹配
• CUDA >= 10.2
• ioPath
• fvcore版本 >= 0.1.4

### Model zoo 和 benchmark

在下面这部分，将简单介绍些PyTorchVideo所提供的Model zoo和benchmark

• Kinetics-400
archdepthpretrainframe length x sample ratetop 1top 5Flops (G) x viewsParams (M)Model
C2DR50-8x871.4689.6825.89 x 3 x 1024.33link
I3DR50-8x873.2790.7037.53 x 3 x 1028.04link
SlowR50-4x1672.4090.1827.55 x 3 x 1032.45link
SlowR50-8x874.5891.6354.52 x 3 x 1032.45link
SlowFastR50-4x1675.3491.8936.69 x 3 x 1034.48link
SlowFastR50-8x876.9492.6965.71 x 3 x 1034.57link
SlowFastR101-8x877.9093.27127.20 x 3 x 1062.83link
SlowFastR101-16x878.7093.61215.61 x 3 x 1053.77link
CSNR101-32x277.0092.9075.62 x 3 x 1022.21link
R(2+1)DR50-16x476.0192.2376.45 x 3 x 1028.11link
X3DXS-4x1269.1288.630.91 x 3 x 103.79link
X3DS-13x673.3391.272.96 x 3 x 103.79link
X3DM-16x575.9492.726.72 x 3 x 103.79link
X3DL-16x577.4493.3126.64 x 3 x 106.15link
MViTB-16x478.8593.8570.80 x 1 x 536.61link
MViTB-32x380.3094.69170.37 x 1 x 536.61link
• Something-Something V2
archdepthpretrainframe length x sample ratetop 1top 5Flops (G) x viewsParams (M)Model
SlowR50Kinetics 4008x860.0485.1955.10 x 3 x 131.96link
SlowFastR50Kinetics 4008x861.6886.9266.60 x 3 x 134.04link
archdepthpretrainframe length x sample rateMAPFlops (G) x viewsParams (M)Model
SlowR50Kinetics 4008x834.7255.10 x 3 x 1031.96link
SlowFastR50Kinetics 4008x837.2466.60 x 3 x 1034.00link
• AVA (V2.2)
archdepthpretrainframe length x sample rateMAPParams (M)Model

### 使用 PyTorchVideo model zoo

PyTorchVideo提供了三种使用方法，并且给每一种都配备了tutorial

• TorchHub，这些模型都已经在TorchHub存在。可以根据实际情况来选择需不需要使用预训练模型。除此之外，官方也给出了TorchHub使用的tutorial
• PySlowFast，使用 PySlowFast workflow 去训练或测试PyTorchVideo models/datasets
• PyTorch Lightning建立一个工作流进行处理，点击查看官方tutorial

### 总结

总的来说，PyTorchVideo的使用与torchvision的使用方法类似，在有了前面的学习基础上，我们可以很快上手PyTorchVideo，具体的可以通过查看官方提供的文档和一些例程来了解使用方法：官方网址

## torchtext简介

torchtext是PyTorch官方用于自然语言处理（NLP）的工具包。自然语言处理也是深度学习的一大应用场景，近年来随着大规模预训练模型的应用，深度学习在人机对话、机器翻译等领域的取得了非常好的效果，也使得NLP相关的深度学习模型获得了越来越多的关注。

由于NLP和CV在数据预处理中的不同，因此NLP的工具包torchtext和torchvision等CV相关工具包也有一些功能上的差异，如：

• 数据集（dataset）定义方式不同
• 数据预处理工具
• 没有琳琅满目的model zoo

### torchtext的主要组成部分

torchtext可以方便的对文本进行预处理，例如截断补长、构建词表等。torchtext主要包含了以下的主要组成部分：

• 数据处理工具 torchtext.data.functionaltorchtext.data.utils
• 数据集 torchtext.data.datasets
• 词表工具 torchtext.vocab
• 评测指标 torchtext.metrics

### torchtext的安装

torchtext可以直接使用pip进行安装：

pip install torchtext


### 构建数据集

#### Field及其使用

Field是torchtext中定义数据类型以及转换为张量的指令。

torchtext 认为一个样本是由多个字段（文本字段，标签字段）组成，不同的字段可能会有不同的处理方式，所以才会有 Field 抽象。

定义Field对象是为了明确如何处理不同类型的数据，但具体的处理则是在Dataset中完成的。

下面通过一个例子来简要说明一下Field的使用：

要注意torchtext的版本，有的版本会有一些导入数据包的差别

• https://stackoverflow.com/questions/66516388/attributeerror-module-torchtext-data-has-no-attribute-field
from torchtext import data

tokenize = lambda x: x.split()
TEXT = data.Field(sequential=True, tokenize=tokenize, lower=True, fix_length=200)
LABEL = data.Field(sequential=False, use_vocab=False)


其中：

• sequential设置数据是否是顺序表示的

• tokenize用于设置将字符串标记为顺序实例的函数

• lower设置是否将字符串全部转为小写

• fix_length设置此字段所有实例都将填充到一个固定的长度，方便后续处理

• use_vocab设置是否引入Vocab object，如果为False，则需要保证之后输入field中的data都是numerical的

构建Field完成后就可以进一步构建dataset了：

from torchtext import data
def get_dataset(csv_data, text_field, label_field, test=False):
fields = [("id", None),  # we won't be needing the id, so we pass in None as the field
("comment_text", text_field), ("toxic", label_field)]
examples = []

if test:
# 如果为测试集，则不加载label
for text in tqdm(csv_data['comment_text']):
examples.append(data.Example.fromlist([None, text, None], fields))
else:
for text, label in tqdm(zip(csv_data['comment_text'], csv_data['toxic'])):
examples.append(data.Example.fromlist([None, text, label], fields))
return examples, fields


这里使用数据csv_data中有"comment_text"和"toxic"两列，分别对应text和label。

train_data = pd.read_csv('train_toxic_comments.csv')
TEXT = data.Field(sequential=True, tokenize=tokenize, lower=True)
LABEL = data.Field(sequential=False, use_vocab=False)

# 得到构建Dataset所需的examples和fields
train_examples, train_fields = get_dataset(train_data, TEXT, LABEL)
valid_examples, valid_fields = get_dataset(valid_data, TEXT, LABEL)
test_examples, test_fields = get_dataset(test_data, TEXT, None, test=True)
# 构建Dataset数据集
train = data.Dataset(train_examples, train_fields)
valid = data.Dataset(valid_examples, valid_fields)
test = data.Dataset(test_examples, test_fields)


可以看到，定义Field对象完成后，通过get_dataset函数可以读入数据的文本和标签，将二者（examples）连同field一起送到torchtext.data.Dataset类中，即可完成数据集的构建。使用以下命令可以看下读入的数据情况：

# 检查keys是否正确
print(train[0].__dict__.keys())
print(test[0].__dict__.keys())
# 抽查内容是否正确
print(train[0].comment_text)


#### 词汇表（vocab）

在NLP中，将字符串形式的词语（word）转变为数字形式的向量表示（embedding）是非常重要的一步，被称为Word Embedding。

这一步的基本思想是收集一个比较大的语料库（尽量与所做的任务相关），在语料库中使用word2vec之类的方法构建词语到向量（或数字）的映射关系，之后将这一映射关系应用于当前的任务，将句子中的词语转为向量表示。

在torchtext中可以使用Field自带的build_vocab函数完成词汇表构建。

TEXT.build_vocab(train)


#### 数据迭代器

from torchtext.data import Iterator, BucketIterator
# 若只针对训练集构造迭代器
# train_iter = data.BucketIterator(dataset=train, batch_size=8, shuffle=True, sort_within_batch=False, repeat=False)

# 同时对训练集和验证集进行迭代器的构建
train_iter, val_iter = BucketIterator.splits(
(train, valid), # 构建数据集所需的数据集
batch_sizes=(8, 8),
device=-1, # 如果使用gpu，此处将-1更换为GPU的编号
sort_key=lambda x: len(x.comment_text), # the BucketIterator needs to be told what function it should use to group the data.
sort_within_batch=False
)

test_iter = Iterator(test, batch_size=8, device=-1, sort=False, sort_within_batch=False)


torchtext支持只对一个dataset和同时对多个dataset构建数据迭代器。

#### 使用自带数据集

与torchvision类似，torchtext也提供若干常用的数据集方便快速进行算法测试。可以查看官方文档寻找想要使用的数据集。

##### Text Classification
• AG_NEWS
• AmazonReviewFull
• AmazonReviewPolarity
• DBpedia
• IMDb
• SogouNews
• SST2
• YelpReviewFull
• YelpReviewPolarity
##### Language Modeling
• PennTreebank
• WkiText-2
• WikiText103
##### Machine Translation
• IWSLT2016
• IWSLT2017
• Multi30k
• Sequence Tagging
• CoNLL2000Chunking
• UDPOS
• CC100
• EnWik9

### 评测指标（metric）

NLP中部分任务的评测不是通过准确率等指标完成的

比如机器翻译任务常用BLEU (bilingual evaluation understudy) score来评价预测文本和标签文本之间的相似程度。

torchtext中可以直接调用torchtext.data.metrics.bleu_score来快速实现BLEU，下面是一个官方文档中的一个例子：

from torchtext.data.metrics import bleu_score
candidate_corpus = [['My', 'full', 'pytorch', 'test'], ['Another', 'Sentence']]
references_corpus = [[['My', 'full', 'pytorch', 'test'], ['Completely', 'Different']], [['No', 'Match']]]
bleu_score(candidate_corpus, references_corpus)

0.8408964276313782


### 其他

值得注意的是，由于NLP常用的网络结构比较固定，torchtext并不像torchvision那样提供一系列常用的网络结构。

模型主要通过torch.nn中的模块来实现，比如torch.nn.LSTMtorch.nn.RNN等。

注意：
对于文本研究而言，当下Transformer已经成为了绝对的主流，因此PyTorch生态中的HuggingFace等工具包也受到了越来越广泛的关注。

### 参考

展开全文
• 'right_eye','left_ear','right_ear','left_shoulder','right_shoulder','left_elbow','right_elbow','left_wrist','right_wrist','left_hip','right_hip','left_knee','right_knee','left_ankle','right_ankle'] ...
• 发现在特征明显时图片分类准确度较高，如对背景干净，特征清晰的金鱼达到了0.999884的置信度，1: 'goldfish, Carassius auratus'，也存在图片分类错误的情况存在，如对于玉米进行检测时998: 'ear, spike, capitulum'...
• ear','right_ear','left_shoulder','right_shoulder','left_elbow','right_elbow','left_wrist','right_wrist','left_hip','right_hip','left_knee','right_knee','left_ankle','right_ankle'] 同样的，我们可以点击...
• ## 一个倒吊人小游戏

千次阅读 2022-04-30 13:46:46
'bring', 'britain', 'broadcast', 'brother', 'brown', 'brush', 'build', 'building', 'bund', 'burn', 'bus', 'business', 'businessman', 'busy', 'but', 'butter', 'butterfly', 'button', 'buy', 'by', 'bye'...
• "build model started" ) start_time = time . time ( ) rgb_scaled = images * 255.0 red , green , blue = tf . split ( rgb_scaled , 3 , 3 ) # 从rgb转成bgr bgr = tf . concat ( [ ...
• 题目描述 从前有个很厉害的人物演讲了一堆很厉害的东西，可是我读书少，认识人不多，你知道这个人叫啥不。。 答案格式wctf{名字} 友情提示1、外国人，只要名字就可以了，就别要姓了，首字母大写。...
• heart revolving_hearts cupid love_letter kiss ring gem bust_in_silhouette busts_in_silhouette speech_balloon footprints thought_balloon dog wolf cat mouse hamster rabbit frog tiger koala bear pig pig_...
• 'beam', 'bean', 'bear', 'beard', 'bearing', 'beast', 'beat', 'beautiful', 'beauty', 'because', 'become', 'bed', 'bee', 'beef', 'beer', 'before', 'beforehand', 'beg', 'begin', 'beginning', 'behalf', '...
• But, what should we do to be a good doctorChen Xuqing who works in the ear-nose-throat department maybe can tell us:‘A good doctor must be responsible, because patients put their health in doctors’...
• 77 ran, 75 ue, 74 and, 74 int, 73 do, 71 ten, 71 able, 62 ear, 62 our, 62 era, 59 end, 59 act, 57 age, 56 mm, 56 eve, 55 ph, 53 ass, 52 man, 49 art, 49 up, 47 ill, 47 cat, 47 eat, 45 mat, 43 tan, 43 ...
• banknote : #> banner : #> bar : ⏸⏭️⏮️⏯️⏸️ #> barber : #> bat : #> bath : ♨ #> bathroom : #> bathtub : #> beach : ‍♀️☀️ #> bear : #> beard : #> bearer : ♒⛎ #> beauty : #> beef : #> ...
• 问题说明： 从标准输入中读入一个英文单词及查找方式，在一个给定的英文常用单词字典文件dictionary3000.txt中查找该单词，返回查找结果（查找到返回1，否则返回0）和查找过程中单词的比较次数。...
• After hearing the funny story , all of us couldn't help laughing ear to ear. 听完了那个滑稽故事，我们忍不住大笑了。 Excuse my interrupting you for a while . 请原谅我打扰你一会儿。 Prof. Smith ...
• 点击上方“优冠教育”关注我们优冠教育 让孩子向冠军冲刺我们在初高中学习英语...有一个year(年)天空很clear(晴朗)下有个bear(狗熊)被割掉ear(耳朵)，气跑了dear(爱人)想起了swear(誓言)流出了tear(眼泪)把眼镜wear(...
• For example, if you wanted to build an API which manages user information, from adding them to an app to erasing their profiles, then these are some of the nouns you might want to use: 例如，如果您想...
• ## 背单词(持续更新）

千次阅读 2021-01-30 09:29:54
新概念英语 claim the protection of the law corner sb： 堵住 possession: 财产 hava lots of complaints about the hotel an accumulation of work to be done puma美洲狮-leopard猎豹 feel obliged(grateful) ...
• import collections f=open("D:\python\Walden.txt","r").read() f=f.replace(',','').replace('.','').replace('"','').replace(':','') f=f.split() r=collections.Counter(f) print(r) ...Counter({'the': 6937,...
• ## walden

千次阅读 2020-11-18 21:56:21
t=open("D:\python\Walden","r").read() t=t.replace(',','').replace('.','').replace('"','').replace(':','') t=t.split() r=collections.Counter(t) print(r) Counter({'the': 6937, 'and': 4547, 'of': 3472...
• 《Walden》单词词频统计 import collections #创建一个新的容器 f = open('E:\学习文件夹\Walden.txt', 'r').read() #打开本地文本文件，r表示以读取方式打开 f = f.replace(',','').replace('.','').replace('"',...
• ## 四级英语词汇大全

千次阅读 2020-12-22 10:29:16
a art.一(个)；每一(个) a.m (缩)上午，午前 abandon vt.丢弃；放弃，抛弃 abbreviation n.节略，缩写，缩短 ability n....able a....abnormal a....aboard ad....abolish vt....about prep....above prep....absence n....absent a....
• dict.txt abandonment n.放弃 abbreviation n.缩写 abeyance n.缓办，中止 abide v....ability n....able adj....abnormal adj....aboard adv....abolish v....abolition n....abortion n....abortive adj....about prep....ab
• #打开并读取文件 file=open(r'c:\Users\Administrator\Desktop\Walden.txt','r') lines=file.readlines() #要把每行拆成单词 words=[] for line in lines: tmp_list =line.split(" ") for word in tmp_list: ...
• 导致 114 build up one's health 健体强身 build a good reputation 树林名誉 115 burn to the ground 把。。烧光 burn sth. down 焚为平地 burn up 烧（旺）起来 116 burst out( crying) 爆发 burst into ( ...

...