Path: csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail From: Terry Reedy Newsgroups: comp.lang.python Subject: Re: Saving Consol outputs in a python script Date: Tue, 3 May 2016 12:50:00 -0400 Lines: 31 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de 7zcwJ8KMm8bgYNJ36D9OUgbVaivh1e970BLNlZO0EVFw== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'objects.': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'script,': 0.09; 'subject:script': 0.09; 'python': 0.10; 'jan': 0.11; 'question.': 0.13; 'subject:python': 0.14; '(there': 0.16; '.py': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'reedy': 0.16; 'skip:~ 20': 0.16; 'subprocess': 0.16; 'tagged': 0.16; 'wrote:': 0.16; 'variable': 0.18; 'skip:s 70': 0.22; 'file.': 0.22; 'am,': 0.23; 'import': 0.24; 'header:In-Reply- To:1': 0.24; 'script': 0.25; '----------': 0.25; 'header:User- Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'function': 0.28; 'values': 0.28; 'interface': 0.29; "i'm": 0.30; 'classes': 0.30; 'probably': 0.31; 'file': 0.34; 'running': 0.34; 'gives': 0.35; 'text': 0.35; 'c++': 0.35; 'saved': 0.35; 'should': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'received:org': 0.37; 'google': 0.39; 'to:addr:python.org': 0.40; 'hello,': 0.40; 'email addr:gmail.com': 0.62; 'received:96': 0.63; 'received:fios.verizon.net': 0.91 X-Injected-Via-Gmane: http://gmane.org/ X-Gmane-NNTP-Posting-Host: pool-96-227-207-81.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.0 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: X-Mailman-Original-References: Xref: csiph.com comp.lang.python:108083 On 5/3/2016 8:14 AM, drewes.mil@gmail.com wrote: > Hello, I'm new to python and have a Question. > > I'm running a c++ file with a python script like: > > import os > import subprocess > > subprocess.call(["~/caffe/build/examples/cpp_classification/classification", "deploy.prototxt", "this.caffemodel", "mean.binaryproto", "labels.txt", "Bild2.jpg"]) > > and it runes fine. On the console it gives me the output: > > ~/Desktop/Downloader/Sym+$ python Run_C.py > ---------- Prediction for Bild2.jpg ---------- > 0.9753 - "Class 1" > 0.0247 - "Class 2" > > > What I need are the 2 values for the 2 classes saved in a variable in the .py script, so that I can write them into a text file. pycaffe is a python interface to caffe. You should look into it and probably use it. Its functions will return python objects. I suspect that is has a function that will return the result of calling the caffe classification function Stackoverflow has question/answers tagged with 'caffe' and 'pycaffe'. (There is also a caffe-users group on google groups.) -- Terry Jan Reedy