This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Copyright 2016 The TensorFlow Authors. All Rights Reserved. | |
| # | |
| # Licensed under the Apache License, Version 2.0 (the "License"); | |
| # you may not use this file except in compliance with the License. | |
| # You may obtain a copy of the License at | |
| # | |
| # http://www.apache.org/licenses/LICENSE-2.0 | |
| # | |
| # Unless required by applicable law or agreed to in writing, software | |
| # distributed under the License is distributed on an "AS IS" BASIS, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @app.route('/captions', methods=['POST']) | |
| @cross_origin(origin='localhost', headers=['Content- Type', 'Authorization']) | |
| def get_differences(): | |
| global success | |
| image_list = request.form["image_paths"].split(',') | |
| model_path = '/Users/harshpyati/personal/fyp/text_gen/im2txt/im2txt/run_inference.py' | |
| command = [ | |
| "python", | |
| model_path, | |
| "--input_files={}".format(image_list) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class PostsActivity : AppCompatActivity() { | |
| private lateinit var postsViewModel: PostsViewModel | |
| override fun onCreate(savedInstance : Bundle?){ | |
| // your code | |
| postsViewModel = ViewModelProvider(this).get(PostsViewModel::class.java) | |
| observeForChanges() | |
| // your code | |
| } | |
| private fun observeForChanges() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class PostsViewModel(application: Application) : AndroidViewModel(application) { | |
| val apiClient = ApiClient() | |
| val listOfPosts: LiveData<List<Posts>> = liveData { | |
| val posts = apiClient.getPosts() | |
| emit(posts) | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private val apiInterface: ApiCalls | |
| init { | |
| val builder = Retrofit.Builder() | |
| .baseUrl("https://jsonplaceholder.typicode.com") | |
| .addConverterFactory(GsonConverterFactory.create(GsonBuilder().create())) | |
| .build() | |
| apiInterface = builder.create(ApiCalls::class.java) | |
| } | |
| suspend fun getPosts(): List<Posts> = apiInterface.getPosts() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import com.app.mvvmposts.model.data.Posts | |
| import retrofit2.http.GET | |
| interface ApiCalls { | |
| @GET("/posts") | |
| suspend fun getPosts(): List<Posts> | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| data class Posts( | |
| val userId: Int, | |
| val id : Int, | |
| val title : String, | |
| val body : String | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| override fun onCreate(savedInstanceState: Bundle?){ | |
| /* Your Existing Code */ | |
| vm = ViewModelProviders.of(this).get(ApiVM::class.java) | |
| showTodo() | |
| } | |
| private fun showTodo(){ | |
| vm.apod.observe(this, Observer { | |
| it?.let { apod -> | |
| displayData(apod) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| val repo: RetroRepo = RetroRepo() | |
| val errorMessage = MutableLiveData<String>() | |
| val apod: LiveData<Photos> = liveData { | |
| try { | |
| val retrievedTodo = repo.getAPOD() | |
| emit(retrievedTodo) | |
| } catch (httpException: HttpException) { | |
| errorMessage.value = httpException.message() | |
| } catch (socketTimeoutException: SocketTimeoutException) { | |
| errorMessage.value = socketTimeoutException.message |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| suspend fun getAPOD(): Photos = webservice.getPhotos() |
NewerOlder