GithubHelp home page GithubHelp logo

zexinyan / medical-report-generation Goto Github PK

View Code? Open in Web Editor NEW
195.0 195.0 65.0 71.75 MB

A pytorch implementation of On the Automatic Generation of Medical Imaging Reports.

Python 50.31% Jupyter Notebook 49.67% Shell 0.02%
image-captioning medical-report pytorch

medical-report-generation's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

medical-report-generation's Issues

the problem of the vocab.pkl

File "dataset.py", line 135, in
vocab = pickle.load(f)
AttributeError: Can't get attribute 'Vocabulary' on <module 'main' from 'dataset.py'>

About _epoch_train and _epoch_val

When i was traning, I've met a problem that the progress came to a standstill. And I've found that it was the function _epoch_train and _epoch_val stopped it, which raises NotImplementedError. I wonder why and how to fix it.

Is there loss a sum function?

the v1 function of class CoAttention, v_att is different from the formula in that paper, is there loss a sum function?

    def v1(self, avg_features, semantic_features, h_sent) -> object:
        """
        only training
        :rtype: object
        """
        W_v = self.bn_v(self.W_v(avg_features))
        W_v_h = self.bn_v_h(self.W_v_h(h_sent.squeeze(1)))

        alpha_v = self.softmax(self.bn_v_att(self.W_v_att(self.tanh(W_v + W_v_h))))
        v_att = torch.mul(alpha_v, avg_features) # over there...........

        W_a_h = self.bn_a_h(self.W_a_h(h_sent))
        W_a = self.bn_a(self.W_a(semantic_features))
        alpha_a = self.softmax(self.bn_a_att(self.W_a_att(self.tanh(torch.add(W_a_h, W_a)))))
        a_att = torch.mul(alpha_a, semantic_features).sum(1) 

        ctx = self.W_fc(torch.cat([v_att, a_att], dim=1))

        return ctx, alpha_v, alpha_a

the question of version

what is the version of the python and torch ?
I have some bugs when I run the tester.py.
for exmple,

Traceback (most recent call last):
File "tester.py", line 502, in
sampler.generate()
File "tester.py", line 144, in generate
sampled_ids = self.word_model.sample(topic, start_tokens)
File "/home/cheng/perl5/Medical-Report-Generation-master/utils/models.py", line 386, in sample
sampled_ids[:, 0] = start_tokens.view(-1, )
File "/usr/local/lib/python3.6/site-packages/torch/tensor.py", line 452, in array
return self.numpy().astype(dtype, copy=False)
TypeError: can't convert CUDA tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.

regarding datset

From where to download the datset, I tried a lot but was unable to find it(i.e data/images folder how to get it)

The problem of dataloader

targets = np.zeros((len(captions), max_sentence_num + 1, max_word_num))
prob = np.zeros((len(captions), max_sentence_num + 1))

When i read the dataset code, i found that the second dim of this two variable added to 1. I don't know why it's set up this way, could anyone help answer this? Thx

pretrained model checkpoint

Hello and thank you for sharing your work!
Could you please provide the last checkpoint for the pretrained model?
Thank you in advance, Lucia

Some question about the code

尝试复现了一下,发现有几个问题(不确定),如遇到相同问题,欢迎讨论。

1.class JsonReader

对于build_vocab.py中的class JsonReader,在构建vocab的时候是没有问题的,但在dataset.py中,self.caption[image_name],image_name已经是图像名称,而不需要像build_vocab.py中用key[序号]来取。

image

所以我认为在运行trainer.py->dataset.py的时候class JsonReader应该改为如下。实验结束也表明修改之后的 JsonReader才会构造出不是空的target。
class JsonReader(object):
    def __init__(self, json_file):
        self.data = self.__read_json(json_file)

    def __read_json(self, filename):
        with open(filename, 'r') as f:
            data = json.load(f)
        return data

    def __getitem__(self, item):
        return self.data[item]

    def __len__(self):
        return len(self.data)

2.Sentence LSTM

和issue #11 中所说的一样,要加上这句话不然状态没法更新只会输出同样的内容。
image

3.Word LSTM

这里的写法有点不太清楚,只能看到原先被注释掉的。* word_mask).sum() * (0.9 ** word_index),这些的含义是什么?
image

4.Class MLC

image

感觉圈起来的那一句,应该返回的torch.topk的[0],[0]才是tensor中的内容,而[1]是序号。不知道这边我有没有理解错。

5.MSEloss

此代码中,在做多标签分类的时候用的是MSEloss(是可行的,但不知道是否和文中对应);而论文原文中所说的是交叉熵分类(感觉应该用sigmoid+BCELoss?)

6.图像的输入

文中提到会把image划分成多个region作为输入,但代码中直接使用的是原image(经过了transform操作中的RandomCrop);是直接讲划分成多个region理解为RandomCrop操作吗?还是有另外的操作方式,这里也不是很清楚。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.