In [2]:
%matplotlib inline
from pycocotools.coco import COCO
import os
import numpy as np
import skimage.io as io
import matplotlib.pyplot as plt
import pickle
from nltk.corpus import wordnet as wn
plt.rcParams['figure.figsize'] = (10.0, 8.0)
from CaptionSaliency import CaptionSaliency as CS
In [3]:
dataType='val2014'
usingSet='5000coco'
dataDir='H:/SG_code/Dataset/COCO/tools' #<====coco path
savefileDir = 'data'
CapSal_train = CS(dataType,usingSet,dataDir,savefileDir)
In [4]:
CapSal_train.compute_distance()
In [2]:
import scipy.io as sio
a = [1,2,3,4]
sio.savemat('data/a.mat',{'a' : a})
test TFIDF
In [6]:
from sklearn.feature_extraction.text import TfidfTransformer
In [7]:
transformer = TfidfTransformer()
In [6]:
counts = [['men','kid','boy'],
... ['men', 'boy'],
... ['kid', 'men', 'kid','kid'],
... ['woman', 'boy', 'girl'],
... ['baby', 'men', 'woman','boy'],
... ['kid']]
In [15]:
# counts2 = [[1,1,1],[1,0,1],[1,3,0],[0,0,1],[1,0,1],[0,1,0]]
counts2 = [[4,1],[3,1]]
tfidf = transformer.fit_transform(counts2)
In [8]:
from sklearn.feature_extraction.text import TfidfVectorizer
In [9]:
vectorizer = TfidfVectorizer(min_df=1)
In [10]:
vectorizer.fit_transform(counts)
In [1]:
import nltk
nltk.download()
Out[1]:
In [ ]: